The following is an excerpt from C++ Common Knowledge : essential intermediate programming by Stephen C. Dewhurst.
I am needing help with the understanding, please.
template <typename T, class A = std::allocator<T>>
class SList{
struct Node{
};
typedef typename A::template rebind<Node>::other NodeAlloc;
}
the following is than written: "As is typical for lists and other node-based containers, our list-of-T does not actually allocate and manipulate Ts. Rather, it allocates and manipulates nodes that contain a member of type T." It continues, "We have some sort of allocator that knows how to allocate objects of type T, but we want to allocate objects of type Node."
I am not understanding the allocator, what exactly does it look like when it allocates the node and what is going on with the rebind. I am unable to understand the inter-workings of the allocator for this SList class. I am especially confused by the allocator's parameter list of T?
Thank you; sincerely,
Josheir
↧