O_o
The `std::set' class doesn't only allocate integers; it allocates whatever it wants by rebinding--with `allocator<???>::rebind'--the allocator to fit the purpose.
There are esoteric data structures that also match the standard requirements; they simply don't perform as well in the real world.
The containers can, basically, do whatever they want so long as the implementation matches the requirements.
However, in practice most implementations will inherit the mutated allocator by virtue of a proxy for the sake of simplicity. (Yes, that's actually one of the simpler ways.)
So then, if we pretend to expand the template inline we might have something like the following code.
Code:
set<int> a;
// ...
set<int, less<int>, allocator<int>> a;
// ...
set<int, less<int>, allocator<int>>: private set_base<int, less<int>, allocator<int>> a;
// ...
set<int, less<int>, allocator<int>>: private set_base<int, less<int>, allocator<int>>: public allocator<int>::rebind<set_base<int, less<int>, allocator<int>::node_type>::type a;
With such a mechanism we can see how the allocation works where facilities need to add a new node.
Code:
pair<iterator, bool> set<???>::insert(const value_type & f)
{
// ...
set<???>::node_type * loc(this->allocate(1));
this->construct(loc, f); // `loc' is now a constructed node type of `node_type' which is an unspecified structure or class
// ...
}
Soma