std::uses_allocator_construction_args
<memory>
T
is not a specialization of std::pair constexpr auto uses_allocator_construction_args( const Alloc& alloc,
T
is a specialization of std::pair constexpr auto uses_allocator_construction_args( const Alloc& alloc,
constexpr auto uses_allocator_construction_args( const Alloc& alloc ) noexcept;
constexpr auto uses_allocator_construction_args( const Alloc& alloc,
constexpr auto uses_allocator_construction_args( const Alloc& alloc,
constexpr auto uses_allocator_construction_args( const Alloc& alloc,
constexpr auto uses_allocator_construction_args( const Alloc& alloc,
constexpr auto uses_allocator_construction_args( const Alloc& alloc,
constexpr auto uses_allocator_construction_args( const Alloc& alloc,
Prepares the argument list needed to create an object of the given type T
by means of uses-allocator construction.
T
is not a specialization of std::pair . Returns std::tuple determined as follows:
- If std::uses_allocator_v <T, Alloc> is false and std::is_constructible_v <T, Args...> is true, returns std::forward_as_tuple (std::forward <Args>(args)...).
- Otherwise, if std::uses_allocator_v <T, Alloc> is true and std::is_constructible_v <T, std::allocator_arg_t, const Alloc&, Args...> is true, returns
std::tuple <std::allocator_arg_t, const Alloc&, Args&&...>(std::allocator_arg, alloc,
std::forward <Args>(args)...). - Otherwise, if std::uses_allocator_v <T, Alloc> is true and std::is_constructible_v <T, Args..., const Alloc&> is true, returns std::forward_as_tuple (std::forward <Args>(args)..., alloc).
- Otherwise, the program is ill-formed.
T
is a specialization of std::pair . For T
that is std::pair <T1, T2>, equivalent to
return std::make_tuple (std::piecewise_construct, std::apply ([&alloc](auto&&... args1) { return std::uses_allocator_construction_args<T1>(alloc, std::forward <decltype(args1)>(args1)...); }, std::forward <Tuple1>(x) ), std::apply ([&alloc](auto&&... args2) { return std::uses_allocator_construction_args<T2>(alloc, std::forward <decltype(args2)>(args2)...); }, std::forward <Tuple2>(y) ) );
T
is a specialization of std::pair . Equivalent to
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::tuple <>{}, std::tuple <>{} );
T
is a specialization of std::pair . Equivalent to
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple (std::forward <U>(u)), std::forward_as_tuple (std::forward <V>(v)) );
T
is a specialization of std::pair . Equivalent to
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple (pr.first), std::forward_as_tuple (pr.second) );
T
is a specialization of std::pair . Equivalent to
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple (std::get<0>(std::move(pr))), std::forward_as_tuple (std::get<1>(std::move(pr))) );
T
is a specialization of std::pair , and given the exposition-only function template
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.
Let the exposition-only class pair-constructor
be defined as
class /*pair-constructor*/ { const Alloc& alloc_; // exposition only NonPair& u_; // exposition only constexpr reconstruct(const std::remove_cv <T>& p) const // exposition only { return std::make_obj_using_allocator <std::remove_cv <T>>(alloc_, p); } constexpr reconstruct(std::remove_cv <T>&& p) const // exposition only { return std::make_obj_using_allocator <std::remove_cv <T>>(alloc_, std::move(p)); } public: constexpr operator std::remove_cv <T>() const { return reconstruct(std::forward <NonPair>(u_)); } };
pair_construction
is a value of type pair-constructor
whose alloc_
and u_
members are alloc
and non_pair
respectively.[edit] Parameters
T
's constructor
T
's first
data member
T
's second
data member
T
's first
data member
T
's second
data member
first
data member will be passed to the constructor of T
's first
data member and second
data member will be passed to the constructor of T
's second
data member
[edit] Return value
std::tuple of arguments suitable for passing to the constructor of T
.
[edit] Notes
The overloads (2-9) provide allocator propagation into std::pair , which supports neither leading-allocator nor trailing-allocator calling conventions (unlike, e.g. std::tuple , which uses leading-allocator convention).
When used in uses-allocator construction, the conversion function of pair-constructor
converts the provided argument to std::pair at first, and then constructs the result from that std::pair by uses-allocator construction.
[edit] Example
Reason: no example
[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 3525 | C++20 | no overload could handle non-pair types convertible to pair
|
reconstructing overload added |
[edit] See also
(function template) [edit]
(function template) [edit]