
AMDG Scott McMurray wrote:
On 19 March 2010 14:02, Eric Whitcombe
wrote: Sorry, if this is a little late to be helpful but I thought I'd add this for historical purposes for anyone looking at this thread to deal with their own problem. All STL containers use allocators to allocate and initialize the memory to store the _elements_ in the container not the node structure. The containers definition of the data structures that support the implentation details are purely internal. The allocator interface is paramterized on the type of the container element.
On that note, does anyone know why allocators are parametrised at all?
Probably because the original idea was just to allocate the type passed. Then someone realized that doesn't work for node-based containers and said, ah, we'll just add rebind.
Since std::vector is the only container that actually allocates from passed-in allocator, it seems like it would have been simpler to just use member templates in a non-templated allocator class.
Well, you still need the pointer, reference, etc. typedefs, somehow.
(Parametrised allocators also mean that nested containers have exponential space requirements for their names, which actually crashed my compiler once when I tried to make a deeply-nested container structure in some recursive-slowdown experiments.)
Yep. Probably no one thought ot this until it too late to do anything about it. In Christ, Steven Watanabe