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