|
|
Member functions | ||||
scoped_allocator_adaptor::construct | ||||
Non-member functions | ||||
(until C++20) | ||||
Deduction guides(C++17) |
Defined in header <scoped_allocator> | ||
template<class T,class...Args> void construct( T* p, Args&&...args); | (1) | |
template<class T1,class T2,class...Args1,class...Args2> void construct(std::pair<T1, T2>* p,std::piecewise_construct_t, | (2) | (until C++20) |
template<class T1,class T2> void construct(std::pair<T1, T2>* p); | (3) | (until C++20) |
template<class T1,class T2,class U,class V> void construct(std::pair<T1, T2>* p, U&& x, V&& y); | (4) | (until C++20) |
(5) | (until C++20) | |
(6) | (until C++20) | |
Helper function templates | ||
template<class T,class...Args> std::tuple</* see below */>/*concat-args*/(std::tuple<Args...>&& tup); | (7) | (exposition only*) (until C++20) |
Constructs an object in allocated, but not initialized storage pointed to byp using the outer allocator and the provided constructor arguments. If the object is of a type that itself uses allocators, or if it isstd::pair(until C++20), passes the inner allocator down to the constructed object.
T
byuses-allocator construction at the uninitialized memory location indicated byp using the outermost allocator.Givenstd::uses_allocator<T, inner_allocator_type>::value asuses_inner:
This overload participates in overload resolution only if | (until C++20) |
Equivalent tostd::apply | (since C++20) |
concat-args
<T1>(std::move(x)),yprime beconcat-args
<T2>(std::move(y)), callsoutermost-construct
(p,std::piecewise_construct, std::move(xprime), std::move(yprime)).Overload | xarg | yarg |
---|---|---|
(4) | std::forward<U>(x) | std::forward<V>(y) |
(5) | xy.first | xy.second |
(6) | std::forward<U>(xy.first) | std::forward<V>(xy.second) |
T
.Contents |
p | - | pointer to allocated, but not initialized storage |
args | - | the constructor arguments to pass to the constructor ofT |
x | - | the constructor arguments to pass to the constructor ofT1 |
y | - | the constructor arguments to pass to the constructor ofT2 |
xy | - | the pair whose two members are the constructor arguments forT1 andT2 |
tup | - | the arguments to be merged |
This function is called (throughstd::allocator_traits) by any allocator-aware object, such asstd::vector, that was given astd::scoped_allocator_adaptor as the allocator to use. Sinceinner_allocator_type
is itself a specialization ofstd::scoped_allocator_adaptor, this function will also be called when the allocator-aware objects constructed through this function start constructing their own members.
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2203 | C++11 | inner allocators were obtained by value-initializing an inner_allocator_type object | obtained by callinginner_allocator() |
LWG 2511 (P0475R1) | C++11 | concat-args might copy elements ofstd::tuples | eliminated all element copy operations |
LWG 2586 | C++11 | only constructions frominner_allocator_type rvalues were checked | checks constructions from non-constinner_allocator_type lvalues instead |
LWG 2975 | C++11 | overload(1) was not constrained | constrained to refusestd::pair |
[static] | constructs an object in the allocated storage (function template)[edit] |
(until C++20) | constructs an object in allocated storage (public member function of std::allocator<T> )[edit] |