Namespaces
Variants
Views
Actions

std::allocator::allocate

From cppreference.com
< cpp‎ | memory‎ | allocator
Revision as of 17:10, 2 November 2012 by P12bot (Talk | contribs)

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

Allocates n * sizeof(T) bytes of uninitialized storage by calling ::operator new(std::size_t), but it is unspecified when and how this function is called. The pointer hint may be used to provide locality of reference: the allocator, if supported by the implementation, will attempt to allocate the new memory block as close as possible to hint.

Contents

Parameters

n - the number of objects to allocate storage for
hint - pointer to a nearby memory location

Return value

Pointer to the first byte of a memory block suitably aligned and sufficient to hold an array of n objects of type T.

Exceptions

Throws std::bad_alloc if allocation fails.

See also

Template:cpp/memory/allocator traits/dcl list allocate