class template

std::allocator

<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 with the standard containers.
Other allocators may be defined. Any class Alloc for which allocator_traits<Alloc> produces a valid instantiation with the appropriate members defined can be used as an allocator on standard containers (Alloc may or may not implement the functionality through member functions).

Except for its destructor, no member of the standard default allocator class template shall introduce data races. Calls to member functions that allocate or deallocate storage shall occur in a single total order, and each such deallocation shall happen before the next allocation (if any) in this order.

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*Pointer to constant element
const_referenceconst T&Reference to constant element
size_typesize_tQuantities of elements
difference_typeptrdiff_tDifference between two pointers

Member functions