std::uses_allocator_construction_args
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <memory> で定義
|
||
| T が std::pair の特殊化でない場合 |
||
template< class T, class Alloc, class... Args > constexpr std::tuple</*see below*/> uses_allocator_construction_args( const Alloc& alloc, Args&&... args) noexcept; |
(1) | (C++20以上) |
| T が std::pair の特殊化である場合 |
||
template< class T, class Alloc, class Tuple1, class Tuple2 > constexpr std::tuple</*see below*/> uses_allocator_construction_args( const Alloc& alloc, std::piecewise_construct_t, Tuple1&& x, Tuple2&& y) noexcept; |
(2) | (C++20以上) |
template< class T, class Alloc > constexpr std::tuple</*see below*/> uses_allocator_construction_args( const Alloc& alloc ) noexcept; |
(3) | (C++20以上) |
template< class T, class Alloc, class U, class V > constexpr std::tuple</*see below*/> uses_allocator_construction_args( const Alloc& alloc, U&& u, V&& v) noexcept; |
(4) | (C++20以上) |
template< class T, class Alloc, class U, class V > constexpr std::tuple</*see below*/> uses_allocator_construction_args( const Alloc& alloc, const std::pair<U,V>& pr) noexcept; |
(5) | (C++20以上) |
template< class T, class Alloc, class U, class V > constexpr std::tuple</*see below*/> uses_allocator_construction_args( const Alloc& alloc, std::pair<U,V>&& pr) noexcept; |
(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) |
アロケータ使用構築の手法によって指定された型のオブジェクトを作成します (関数テンプレート) |
| アロケータ使用構築の手法によって指定されたメモリ位置に指定された型のオブジェクトを作成します (関数テンプレート) |