<memory>
The <memory>
header declares function and class templates for
allocating and using memory, such as the auto_ptr<>
smart pointer, algorithms for
working with uninitialized memory, and a standard allocator for use with
the standard containers.
The auto_ptr
class template
provides a simple ownership model for working with pointers. It can be
extremely useful for writing exception-safe code. On the other hand,
copying an auto_ptr<>
object
does not produce an exact copy (ownership of the pointer is
transferred), so auto_ptr<>
objects cannot be stored in standard containers.
Several functions work with uninitialized memory, which can be
helpful when implementing a container. For example, an implementation of
vector
must allocate an uninitialized
array of objects and initialize elements of the array as they are
needed. The uninitialized_
. . .
functions can come in handy for that purpose.
The allocator
class template
manages memory allocation and deallocation and the construction and
destruction of objects in the memory it manages. It is the default
allocator for all the standard containers.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.