plf_colony
plf_colony copied to clipboard
Allocator without empty constructor?
Colony appears to assume/expect allocators with empty constructors, and will lapse to using empty-constructed allocators even when passing in an allocator constructed with arguments. Am I misunderstanding Colony's relationship with allocators? Otherwise, is there any way this restriction/assumption could be relaxed and the passed allocator could be copied instead of reconstructed by type? Vectors, by comparison, will accept and properly use such an allocator.
In particular, this seems to revolve around the element packaging (ebco_pair) for empty-base-class optimization. Perhaps due to size constraints?
Thanks!
Hey - I got a lot of conflicting advice about this - initially I was told, you Should use EBCO for that. Then later I got told, well, that could be a problem if we get stateful allocators. My knowledge of the current state of allocators is limited. So are you saying stateful allocators are more common now? If so, I will look at it. Of course, I'd prefer if this is just a theoretical constraint, that it remain EBCO to save memory, and dev time-
I don't think it's critical. I have a use case with a stateful allocator since I draw situationally from different memory pools, but I can work around it if needs be.
Okay, I will look into it. It may be next year before I come up with something. One of the issues is that the allocator is rebound for several other types (skipfield and group structure) and those instances are also EBCO'd into substructures, so it's finding a way of rebinding and passing the rebound types on without wasting too much memory. Will see.
The advice I got when I looked into this recently is that it's a requirement for C++ allocators to have a cheap/shallow copy, and that the copy act as if it were the original (presumably using shared pointers or the like). If this were the case then this would resolve the issue of using allocators with EBCO, and rebinding them, would you say that's correct? If that's the case the only thing left to do is to include variadic template parameters for colony which are supplied to the allocator itself. At that point I could probably use some help, and if you have any suggestions for how to do so, that'd be grand.
Fixed