The general utilities library requirements include requirements for allocators. Allocators are objects that contain information about the container. This includes information concerning pointer types, the type of their difference, the size of objects in this allocation, also the memory allocation and deallocation information. All of the standard containers are parameterized in terms of allocators.
The allocator class includes the following members
| Expression | Meaning |
|---|---|
| pointer | A pointer to a type |
| const_pointer | A pointer to a const type |
| reference | A reference of a type |
| const_reference | A reference to a const type |
| value_type | A type identical to the type |
| size_type | An unsigned integer that can represent the largest object in the allocator |
| difference_type | A signed integer that can represent the difference between any to pointers in the allocator |
| rebind | The template member is effectively a typedef of the type to which the allocator is bound |
| address(type) | Returns the address of type |
| address(const type) | Returns the address of the const type |
| allocate(size) | Returns the allocation of size |
| allocate(size, address) | Returns the allocation of size at the address |
| max_size | The largest value that can be passed to allocate |
| Ax == Ay | Returns a bool true if the storage of each allocator can be deallocated by the other |
| Ax != Ay | Returns a bool true if the storage of each allocator can not be deallocated by the other |
| T() | Constructs an instance of type |
| T x(y) | x is constructed with the values of y |
Allocator template parameters must meet additional requirements
Implementation-defined allocators are allowed.
| Member | Type |
|---|---|
| pointer | T* |
| const_pointer | T const* |
| size_type | size_t |
| difference_type | ptrdiff_t |