The default class for managing
storage in the Standard C++ Library.
Library
Standards<ToolKit>
Declaration
#include <memory>
template< class T >
class allocator
Interface
Constructor
allocator()
Constructs an allocator
to manage storage.
Constructor
allocator(
allocator_impl* implementation )
Constructs an allocator
that uses the implementation object to allocate
and release raw storage.
Constructor
allocator(
const allocator< T >& other )
Constructs an allocator
that uses the same implementation as other to
allocate and release raw storage.
Destructor
~allocator()
Destroys this allocator.
=
allocator&
operator=( const allocator< T >& other
)
Assigns this allocator to
use the same implementation as other .
==
bool
operator==( const allocator< T >& other
) const
Returns true
.
address
T*
address( T& object )
const
Returns a pointer to object
.
address
const
T* address( const T& object )
const
Returns a constant
pointer to object .
allocate
T*
allocate( size_t n ,
const void* hint )
Allocates storage for n
objects, using hint (default 0
) if necessary.
construct
void
construct( T* ptr ,
const T& value )
Constructs an object at
location ptr using value
(default T() ).
deallocate
void
deallocate( T* ptr )
Releases the storage
pointed to by ptr .
destroy
void
destroy( T* ptr )
Destroys the object at
location ptr .
max_size
size_t
max_size() const
Returns the maximum
number of objects that can be allocated at once.
raw_allocate
void*
raw_allocate( size_t size ,
size_t n ,
const void* hint )
Allocates raw storage for
n objects, with each object requiring size
bytes. The optional parameter hint can be used to
optimize storage management. This method is a non-standard extension to the
standard allocator, but is necessary to work around current compiler
limitations.
raw_deallocate
void
raw_deallocate( void* ptr )
Releases the raw storage
pointed to by ptr . This method is a non-standard
extension to the standard allocator, but is necessary to work around current
compiler limitations.