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
is a specialization of
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
のオブジェクトを
uses-allocator構築
によって作成するために必要な引数リストを準備します。
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
の特殊化である場合にのみ、オーバーロード解決に参加します。
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) ) );
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
)
が未評価オペランドとして考慮された場合、ill-formedとなります。
説明専用のクラス
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
は型
pair-constructor
の値であり、その
alloc_
および
u_
メンバはそれぞれ
alloc
および
non_pair
です。
目次 |
パラメータ
| 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 に変換する単一引数 |
戻り値
std::tuple
T
のコンストラクタに渡すのに適した引数の。
注記
オーバーロード (2-9) はアロケータの伝播を std::pair に提供します。これは先行アロケータ呼び出し規約も後続アロケータ呼び出し規約もサポートしていません(例えば std::tuple とは異なり、こちらは先行アロケータ規約を使用します)。
使用アロケータ構築で使用される場合、
pair-constructor
の変換関数は、まず提供された引数を
std::pair
に変換し、その後その
std::pair
から使用アロケータ構築によって結果を構築します。
例
|
このセクションは不完全です
理由: 例がありません |
欠陥報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3525 | C++20 |
pair
に変換可能な非
pair
型を扱えるオーバーロードが存在しなかった
|
再構築オーバーロードが追加された |
関連項目
|
(C++11)
|
指定された型がuses-allocator構築をサポートするかどうかをチェックする
(クラステンプレート) |
|
(C++20)
|
uses-allocator構築によって指定された型のオブジェクトを作成する
(関数テンプレート) |
|
uses-allocator構築によって指定されたメモリ位置に指定された型のオブジェクトを作成する
(関数テンプレート) |