Standard C++ Library Reference ISO/IEC (VERSION3)

};
allocator
template<class Ty>
class allocator {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef Ty *pointer;
typedef const Ty *const_pointer;
typedef Ty& reference;
typedef const Ty& const_reference;
typedef Ty value_type;
pointer address(reference val) const;
const_pointer address(const_reference val) const;
template<class Other>
struct rebind;
allocator();
template<class Other>
allocator(const allocator<Other>& right);
template<class Other>
allocator& operator=(const allocator<Other>& right);
template<class Other>
pointer allocate(size_type count, const Other *hint = 0);
void deallocate(pointer ptr, size_type count);
void construct(pointer ptr, const Ty& val);
void destroy(pointer ptr);
size_type max_size() const;
};
The template class describes an object that manages storage allocation and freeing for arrays of
objects of type Ty. An object of class allocator is the default allocator object specified in
the constructors for several container template classes in the Standard C++ library.
Template class allocator supplies several type definitions that are rather pedestrian. They
hardly seem worth defining. But another class with the same members might choose more
interesting alternatives. Constructing a container with an allocator object of such a class gives
individual control over allocation and freeing of elements controlled by that container.
For example, an allocator object might allocate storage on a private heap. Or it might
allocatestorage on a far heap, requiring nonstandard pointers to access the allocated objects. Or
it might specify, through the type definitions it supplies, that elements be accessed through
special accessor objects that manage shared memory, or perform automatic garbage