This section describes
bitset—class templates that don’t quite fit in the other sections.
An allocator is an abstraction of the
delete expressions. The standard containers use allocators to allocate and free memory, and to construct and destroy objects that reside in a container.
The standard library defines the
allocator class template, which is the default allocator for every standard container. You can supply a different allocator as long as it provides the same interface as the standard allocator.
Implementing a new allocator is trickier than it seems at first and is beyond the scope of this book. This section describes how to use the standard
allocator class template.
The following are the member types of
typedef const T*
A type for a pointer to
typedef const T&
A type for a
A type to represent the difference of any two pointers that the allocator returns from
A pointer type.
template <class U> struct
Binds the allocator object to a different value type. The
rebind class has a single typedef,
other, which is an instance of
allocator, but with
U as the template parameter. The
rebind template is necessary for standard containers that allocate helper objects, such as link nodes, rather than allocating values directly. If you are not implementing a standard container, you probably don’t need to understand ...