The std::allocator class template is the default Allocator used by all standard library containers if no user-specified allocator is provided. The default allocator is stateless, that is, all instances of the given allocator are interchangeable, compare equal and can deallocate memory allocated by any other instance of the same allocator type.

Specialization for void lacks the member typedefs reference, const_reference, size_type and difference_type. This specialization declares no member functions.

All custom allocators also must be stateless.

(until C++11)

Custom allocators may contain state. Each container or another allocator-aware object stores an instance of the supplied allocator and controls allocator replacement through std::allocator_traits.

Non-member functions

Notes

The member template class rebind provides a way to obtain an allocator for a different type. For example,

std::list<T, A> allocates nodes of some internal type Node<T>, using the allocator A::rebind<Node<T>>::other

(until C++11)

std::list<T, A> allocates nodes of some internal type Node<T>, using the allocator std::allocator_traits<A>::rebind_alloc<Node<T>>, which is implemented in terms of A::rebind<Node<T>>::other if A is an std::allocator