Namespaces
Variants
Views
Actions

std::allocator::construct

From cppreference.com
< cpp‎ | memory‎ | allocator
Revision as of 17:08, 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 >
void construct( pointer p, const_reference val );
</td>

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

<td >
template< class U, class... Args >
void construct( U* p, Args&&... args );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

Constructs an object of type T in allocated uninitialized storage pointed to by p, using placement-new

1) Calls new((void *)p) T(val)

2) Calls ::new((void *)p) U(std::forward<Args>(args)...)


Parameters

p - pointer to allocated uninitialized storage
val - the value to use as the copy constructor argument
args... - the constructor arguments to use

Return value

(none)

See also

Template:cpp/memory/allocator traits/dcl list constructTemplate:cpp/memory/new/dcl list operator new