
Christian Schladetsch wrote:
The motivation for my original proposal was to provide a framework for heterogenous containers, and came from discussions about how cloning works in ptr_container.
I wanted a way to make the cloning operation for ptr_container to use the same allocator that the container uses (and indeed, have the container use the correct allocator at all!).
Standard allocators are inherently incompatible with the very idea of cloneable objects, since the type information is supposed to be lost. The only sensible thing you can do (IMHO) is use a standard allocator of char or use an allocator interface similar to that of malloc or operator new. I personally never understood why they tied the type into the allocator. Having just the size and alignment would be so much better.
You simply have to use emplace semantics for these containers; otherwise you aren't respecting the allocator
For when you copy the container later, do you maybe add a pointer overhead per object on your heterogeneous list to reference a rightly rebound function for cloning with the given container allocator? Not something very nice, since it could be avoided.