Top of document
©Copyright 1999 Rogue Wave Software

An Overview of the Standard Library Allocators

The Standard C++ allocator interface encapsulates the types and functions needed to manage the storage of data in a generic way. The interface provides:

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.


Top of document