Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
memory
classes:
allocator
auto_ptr
auto_ptr_ref
raw_storage_iterator
functions:
get_temporary_buffer
return_temporary_buffer
uninitialized_copy
uninitialized_fill
uninitialized_fill_n
allocator
allocator::allocator
allocator::~allocator
member functions:
allocator::address
allocator::allocate
allocator::construct
allocator::deallocate
allocator::destroy
allocator::max_size


allocator::allocate

public member function
pointer allocate (size_type n, allocator<void>::const_pointer hint=0);

Allocate block of storage

Attempts to allocate a block of storage with a size large enough to contain n elements of type T (the allocator's template parameter), and returns a pointer to the first element.

The storage is aligned appropriately for objects of type T, but they are not constructed.

In the default allocator, the block of storage is allocated using ::operator new one or more times, and throws bad_alloc if it cannot allocate the total amount of storage requested.

Parameters

n
Number of elements (each of size sizeof(T)) to be allocated.
In allocator, the member type size_type is an alias of size_t, which is an unsigned integral type.
[/dd]
hint
Either 0 or a value previously obtained by another call to allocate and not yet freed with deallocate.
When it is not 0, this value may be used as a hint to improve performance by allocating the new block near the one specified.

Return value

A pointer to the initial element in the block of storage.
allocator throws bad_alloc if it cannot allocate the requested amount of storage.
In allocator, member type pointer is an alias of T*.[/dd]


See also