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 for any object's size;
storage allocation and deallocation primitives;
object construction and destruction primitives.
The 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 Standard C++ Library provides a default allocator class, allocator, that implements this interface using the Standard new and delete operators for all storage management.
This section briefly describes how to use allocators with existing containers, then discusses what you need to consider when designing your own allocators. The later section of this guide, entitled "Building Containers and Generic Algorithms" describes what you must consider when designing containers that use allocators.
©Copyright 1996, Rogue Wave Software, Inc.