allocator


class template
<memory>
template <class T> class allocator;

Default allocator

Allocators are classes that define memory models to be used by some parts of the Standard Library, and most specifically, by STL containers.

This section describes the default allocator template allocator (lowercase). This is the allocator that all standard containers will use if their last (and optional) template parameter is not specified, and is the only predefined allocator in the standard library.

Other allocators may be defined. Any class having the same members as this default allocator and following its minimum requirements can be used as an allocator -- notice that only under very specific circumstances this is needed.

Technically, a memory model described by allocators might be specialized for each type of object to be allocated and even may store local data for each container they work with. Although this does not happen with the default allocator.

The class template of allocator is declared as:
 
template < class T > class allocator;

Taking one template parameter (which is assumed to be T in this entire reference).

Member types

memberdefinition in allocatorrepresents
value_typeTElement type
pointerT*Pointer to element
referenceT&Reference to element
const_pointerconst T*Constant pointer to element
const referenceconst T&Constant reference to element
size_typesize_tQuantities of elements
difference_typeptrdiff_tDifference between two pointers


Member functions