plf_colony icon indicating copy to clipboard operation
plf_colony copied to clipboard

Allocator without empty constructor?

Open recatek opened this issue 6 years ago • 4 comments
trafficstars

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!

recatek avatar Dec 01 '18 05:12 recatek

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-

mattreecebentley avatar Dec 02 '18 21:12 mattreecebentley

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.

recatek avatar Dec 02 '18 23:12 recatek

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.

mattreecebentley avatar Dec 04 '18 22:12 mattreecebentley

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.

mattreecebentley avatar Nov 29 '20 06:11 mattreecebentley

Fixed

mattreecebentley avatar Aug 27 '22 22:08 mattreecebentley