The Standard C++ allocator interface encapsulates the types and functions needed to manage the storage of data in a generic way. The interface provides:
pointer and reference types
the type of the difference between pointers
the type to describe the size of a block of storage
storage allocation and deallocation primitives
object construction and destruction primitives.
This allocator interface wraps the mechanism for managing data storage, and separates this mechanism from the classes and functions used to maintain associations between data elements. This eliminates the need to rewrite containers and algorithms to suit different storage mechanisms. The interface lets you encapsulate all the storage mechanism details in an allocator, then provide that allocator to an existing container when appropriate.
The C++ Standard Library provides a default allocator class, allocator, that implements this interface using the standard new and delete operators for all storage management.
This chapter briefly describes how to use allocators with existing containers, then discusses what you need to consider when designing your own allocators. Chapter 16 describes what you must consider when designing containers that use allocators.