std::uses_allocator_construction_args
| ヘッダ <memory> で定義 |
||
T は std::pair の特殊化ではない |
||
| template< class T, class Alloc, class... Args > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(1) | (C++20以降) |
T は std::pair の特殊化である |
||
| template< class T, class Alloc, class Tuple1, class Tuple2 > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(2) | (C++20以降) |
| template< class T, class Alloc > constexpr auto uses_allocator_construction_args( const Alloc& alloc ) noexcept; |
(3) | (C++20以降) |
| template< class T, class Alloc, class U, class V > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(4) | (C++20以降) |
| template< class T, class Alloc, class U, class V > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(5) | (C++23から) |
| template< class T, class Alloc, class U, class V > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(6) | (C++20以降) |
| template< class T, class Alloc, class U, class V > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(7) | (C++20以降) |
| template< class T, class Alloc, class U, class V > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(8) | (C++23から) |
| template< class T, class Alloc, class NonPair > constexpr auto uses_allocator_construction_args( const Alloc& alloc, |
(9) | (C++20以降) |
アロケータを使用する構築によって、指定された型 T のオブジェクトを作成するために必要な引数リストを準備します。
T が std::pair の特殊化でない場合にのみオーバーロード解決に参加します。以下のように決定される std::tuple を返します。- std::uses_allocator_v<T, Alloc> が false であり、かつ std::is_constructible_v<T, Args...> が true の場合、std::forward_as_tuple(std::forward<Args>(args)...) を返します。
- そうでなく、std::uses_allocator_v<T, Alloc> が true であり、かつ std::is_constructible_v<T, std::allocator_arg_t, const Alloc&, Args...> が true の場合、以下を返します。
std::tuple<std::allocator_arg_t, const Alloc&, Args&&...>(std::allocator_arg, alloc,
std::forward<Args>(args)...). - そうでなく、std::uses_allocator_v<T, Alloc> が true であり、かつ std::is_constructible_v<T, Args..., const Alloc&> が true の場合、std::forward_as_tuple(std::forward<Args>(args)..., alloc) を返します。
- それ以外の場合、プログラムは不適格となります。
T が std::pair の特殊化である場合にのみオーバーロード解決に参加します。std::pair<T1, T2> である T について、以下と等価です。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 が std::pair の特殊化である場合にのみオーバーロード解決に参加します。以下と等価です。return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::tuple<>{}, std::tuple<>{} );
T が std::pair の特殊化である場合にのみオーバーロード解決に参加します。以下と等価です。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 が std::pair の特殊化である場合にのみオーバーロード解決に参加します。以下と等価です。return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple(pr.first), std::forward_as_tuple(pr.second) );
T が std::pair の特殊化である場合にのみオーバーロード解決に参加します。以下と等価です。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 が std::pair の特殊化である場合にのみオーバーロード解決に参加し、かつ、提示のみの関数テンプレートであるtemplate<class A, class B> void /*deduce-as-pair*/(const std::pair<A, B>&);
、/*deduce-as-pair*/(non_pair) は、評価されないオペランドとみなされると不正形式になります。
提示のみのクラス pair-constructor を以下のように定義します。
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 は alloc_ メンバーと u_ メンバーがそれぞれ alloc と non_pair である pair-constructor 型の値です。目次 |
[編集] パラメーター
| alloc | - | 使用するアロケータ |
| args | - | T のコンストラクタに渡す引数 |
| x | - | T の first データメンバーのコンストラクタに渡す引数のタプル |
| y | - | T の second データメンバーのコンストラクタに渡す引数のタプル |
| u | - | T の first データメンバーのコンストラクタに渡す単一の引数 |
| v | - | T の second データメンバーのコンストラクタに渡す単一の引数 |
| pr | - | first データメンバーが T の first データメンバーのコンストラクタに渡され、second データメンバーが T の second データメンバーのコンストラクタに渡されるペア |
| non_pair | - | さらなる構築のために std::pair に変換する単一の引数 |
[編集] 戻り値
T のコンストラクタに渡すのに適した引数の std::tuple。
[編集] 備考
オーバーロード (2-9) は、先行アロケータ呼び出し規約も後続アロケータ呼び出し規約もサポートしない(例:先行アロケータ規約を使用する std::tuple とは異なり)std::pair へのアロケータ伝播を提供します。
アロケータを使用する構築で使用される場合、pair-constructor の変換関数は、まず提供された引数を std::pair に変換し、次にその std::pair からアロケータを使用する構築によって結果を構築します。
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 欠陥報告
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 3525 | C++20 | pair に変換可能な非pair型を処理できるオーバーロードがない |
再構築オーバーロードが追加された |
[編集] 関連項目
| (C++11) |
指定された型が uses-allocator 構築をサポートしているかどうかをチェックします (クラステンプレート) |
| (C++20) |
uses-allocator 構築によって、与えられた型のオブジェクトを作成します (関数テンプレート) |
| uses-allocator 構築によって、指定されたメモリ位置に与えられた型のオブジェクトを作成します (関数テンプレート) |