The template class describes an object that manages storage allocation and freeing for arrays of objects of type Type. An object of class allocator is the default allocator object specified in the constructors for several container template classes in the Standard C++ Library.
The type of object for which storage is being allocated or deallocated.
All the Standard Template Library containers have a template parameter that defaults to allocator. Constructing a container with a custom allocator provide control over allocation and freeing of that container's elements.
For example, an allocator object might allocate storage on a private heap or in shared memory, or it might optimize for small or large object sizes. It might also specify, through the type definitions it supplies, that elements be accessed through special accessor objects that manage shared memory, or perform automatic garbage collection. Hence, a class that allocates storage using an allocator object should use these types for declaring pointer and reference objects, as the containers in the Standard C++ Library do.
(C_++98/03 only)When you derive from allocator class, you have to provide a rebind struct, whose _Other typedef references your newly-derived class.
Thus, an allocator defines the following types:
pointer behaves like a pointer to Type.
const_pointer behaves like a const pointer to Type.
reference behaves like a reference to Type.
const_reference behaves like a const reference to Type.
These Types specify the form that pointers and references must take for allocated elements. (allocator::pointer is not necessarily the same as Type* for all allocator objects, even though it has this obvious definition for class allocator.)
C++11 and later: To enable move operations in your allocator, use the minimal allocator interface and implement copy constructor, == and != operators, allocate and deallocate. For more information and an example, see Allocators
Constructors used to create allocator objects.
A type that provides a constant pointer to the type of object managed by the allocator.
A type that provides a constant reference to type of object managed by the allocator.
A signed integral type that can represent the difference between values of pointers to the type of object managed by the allocator.
A type that provides a pointer to the type of object managed by the allocator.
A type that provides a reference to the type of object managed by the allocator.
An unsigned integral type that can represent the length of any sequence that an object of template class allocator can allocate.
A type that is managed by the allocator.
Finds the address of an object whose value is specified.
Allocates a block of memory large enough to store at least some specified number of elements.
Constructs a specific type of object at a specified address that is initialized with a specified value.
Frees a specified number of objects from storage beginning at a specified position.
Calls an objects destructor without deallocating the memory where the object was stored.
Returns the number of elements of type Type that could be allocated by an object of class allocator before the free memory is used up.
A structure that enables an allocator for objects of one type to allocate storage for objects of another type.
Assigns one allocator object to another allocator object.