std::pmr::polymorphic_allocator<T>::construct
void construct( U* p, Args&&... args );
void construct( std::pair <T1, T2>* p,
std::piecewise_construct_t,
std::tuple <Args1...> x,
(until C++20)
void construct( std::pair <T1, T2>* p );
(until C++20)
void construct( std::pair <T1, T2>* p, U&& x, V&& y );
(until C++20)
void construct( std::pair <T1, T2>* p, const std::pair <U, V>& xy );
(until C++20)
void construct( std::pair <T1, T2>* p, std::pair <U, V>&& xy );
(until C++20)
void construct( std::pair <T1, T2>* p, NonPair&& non_pair );
(until C++20)
Constructs an object in allocated, but not initialized storage pointed to by p the provided constructor arguments. If the object is of type that itself uses allocators, or if it is std::pair, passes *this down to the constructed object.
U
by means of uses-allocator construction at the uninitialized memory location indicated by p, using *this as the allocator. This overload participates in overload resolution only if U
is not a specialization of std::pair .(until C++20)T1
or T2
is allocator-aware, modifies the tuples x and y to include this->resource()
, resulting in the two new tuples xprime
and yprime
, according to the following three rules:T1
is not allocator-aware (std::uses_allocator <T1, polymorphic_allocator>::value==false) and std::is_constructible <T1, Args1...>::value==true, then xprime
is x, unmodified.T1
is allocator-aware (std::uses_allocator <T1, polymorphic_allocator>::value==true), and its constructor takes an allocator tag (std::is_constructible <T1, std::allocator_arg_t, polymorphic_allocator, Args1...>::value==true, then xprime
is
std::tuple_cat (std::make_tuple (std::allocator_arg, *this), std::move(x)).T1
is allocator-aware (std::uses_allocator <T1, polymorphic_allocator>::value==true), and its constructor takes the allocator as the last argument (std::is_constructible <T1, Args1..., polymorphic_allocator>::value==true), then xprime
is std::tuple_cat (std::move(x), std::make_tuple (*this)).T2
and the replacement of y with yprime
.xprime
and yprime
are constructed, constructs the pair p in allocated storage as if by ::new((void *) p) pair<T1, T2>(std::piecewise_construct, std::move(xprime), std::move(yprime));.construct(p, std::piecewise_construct, std::forward_as_tuple (std::forward <U>(x)), std::forward_as_tuple (std::forward <V>(y)))
construct(p, std::piecewise_construct, std::forward_as_tuple (xy.first), std::forward_as_tuple (xy.second))
construct(p, std::piecewise_construct, std::forward_as_tuple (std::forward <U>(xy.first)), std::forward_as_tuple (std::forward <V>(xy.second)))
template< class A, class B > void /*deduce-as-pair*/( const std::pair <A, B>& );
, /*deduce-as-pair*/(non_pair) is ill-formed when considered as an unevaluated operand. Equivalent to
construct<T1, T2, T1, T2>(p, std::forward <NonPair>(non_pair));
[edit] Parameters
T
T1
T2
T1
and T2
pair
argument to convert to pair
for further construction
[edit] Return value
(none)
[edit] Notes
This function is called (through std::allocator_traits ) by any allocator-aware object, such as std::pmr::vector (or another std::vector that was given a std::pmr::polymorphic_allocator
as the allocator to use).
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2969 | C++17 | uses-allocator construction passed resource()
|
passes *this |
LWG 2975 | C++17 | first overload is mistakenly used for pair construction in some cases | constrained to not accept pairs |
LWG 3525 | C++17 | no overload could handle non-pair types convertible to pair
|
reconstructing overload added |