std::uses_allocator_construction_args
提供: cppreference.com
ヘッダ <memory> で定義
|
||
T が std::pair の特殊化でない場合 |
||
template< class T, class Alloc, class... Args > constexpr std::tuple</*see below*/> uses_allocator_construction_args( |
(1) | (C++20以上) |
T が std::pair の特殊化である場合 |
||
template< class T, class Alloc, class Tuple1, class Tuple2 > constexpr std::tuple</*see below*/> uses_allocator_construction_args( |
(2) | (C++20以上) |
template< class T, class Alloc > constexpr std::tuple</*see below*/> uses_allocator_construction_args( |
(3) | (C++20以上) |
template< class T, class Alloc, class U, class V > constexpr std::tuple</*see below*/> uses_allocator_construction_args( |
(4) | (C++20以上) |
template< class T, class Alloc, class U, class V > constexpr std::tuple</*see below*/> uses_allocator_construction_args( |
(5) | (C++20以上) |
template< class T, class Alloc, class U, class V > constexpr std::tuple</*see below*/> uses_allocator_construction_args( |
(6) | (C++20以上) |
アロケータ使用構築の手法によって指定された型 T
のオブジェクトを作成するために必要な引数リストを準備します。
1) このオーバーロードは、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) を返します。
- そうでなければ、プログラムは ill-formed です。
2) このオーバーロードは、T が std::pair の特殊化である場合にのみ、オーバーロード解決に参加します。 T = std::pair<T1, T2> に対して、以下と同等です。
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)) );
3) このオーバーロードは、T が std::pairの特殊化である場合にのみ、オーバーロード解決に参加します。 以下と同等です。
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::tuple<>{}, std::tuple<>{} );
4) このオーバーロードは、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)) );
5) このオーバーロードは、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) );
6) このオーバーロードは、T が std::pair の特殊化である場合にのみ、オーバーロード解決に参加します。 以下と同等です。
return std::uses_allocator_construction_args<T>( alloc, std::piecewise_construct, std::forward_as_tuple(std::move(pr).first), std::forward_as_tuple(std::move(pr).second));
目次 |
[編集] 引数
alloc | - | 使用するアロケータ |
args | - | T のコンストラクタに渡す引数 |
x | - | T の .first のコンストラクタに渡す引数のタプル |
y | - | T の .second のコンストラクタに渡す引数のタプル |
u | - | T の .first のコンストラクタに渡す単一の引数 |
v | - | T の .second のコンストラクタに渡す単一の引数 |
pr | - | .first が T の .first のコンストラクタに渡され .second が T の .second のコンストラクタに渡されるペア |
[編集] 戻り値
T
のコンストラクタに渡すのに適した引数の std::tuple。
[編集] 例
This section is incomplete Reason: no example |
[編集] ノート
オーバーロード (2-6) は std::pair へのアロケータの伝播を提供します。 std::pair は (std::tuple などとは異なり) 先頭アロケータ呼び出し規約と末尾アロケータ呼び出し規約のいずれもサポートしません。
[編集] 関連項目
(C++11) |
指定された型がアロケータ使用構築をサポートしているかどうか調べます (クラステンプレート) |
(C++20) |
アロケータ使用構築の手法によって指定された型のオブジェクトを作成します (関数テンプレート) |
アロケータ使用構築の手法によって指定されたメモリ位置に指定された型のオブジェクトを作成します (関数テンプレート) |