Namespaces
Variants
Views
Actions

std::allocator_traits::allocate

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

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <memory>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td >
static pointer allocate( Alloc& a, size_type n );
</td>

<td > (1) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
static pointer allocate( Alloc& a, size_type n, const_void_pointer hint );
</td>

<td > (2) </td> <td > (since C++11) </td> </tr> Template:ddcl list end

1) Uses the allocator a to allocate n*sizeof(Alloc::value_type) bytes of uninitialized storage, by calling a.allocate(n)

2) Uses the allocator a to allocate n*sizeof(Alloc::value_type) bytes of uninitialized storage with the memory locality hint hint. Calls a.allocate(n, hint) if possible. If not possible (e.g. a has no two-argument member function allocate()), calls a.allocate(n)

Parameters

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

Return value

The pointer returned by the call to a.allocate(n)

See also

Template:cpp/memory/allocator/dcl list allocate