
AMDG Eric Whitcombe wrote:
I'm sorry but you would have to point me to some sources where you are getting your info. I can point you to Josuttis "The C++ Standard Library: A Tutorial and Reference" p 734.
Look at any implementation of the standard library. Here's the struct that's actually allocated in one: struct _Node { // tree node <snip constructor> <snip tree links> value_type _Myval; // the stored value, unused if head <snip extra bookkeeping information> }; Note that because the node holds the object by value, there is no way to separate allocation of the node from allocation of the value.
In part about rebind: "This template structure provides the ability that an allocator may allocate storage of another type indirectly." This page gives detailed example vis-a-vis std::deque. I won't quote it at length.
I don't see how this leads to the conclusion that the container must allocate exactly the type you give it. Maybe I'm not understanding you correctly?
In short rebind allows you to abstract the implementation of allocating the internal data structures and link it to the allocation of dynamic type of the element.
The standard actually does not specify what is actually allocated. The allocator is just along for the ride for all the containers, and it's assumed that anything that the container needs to allocate will use either the allocator or a rebound form of the allocator. In Christ, Steven Watanabe