std::in_place, std::in_place_type, std::in_place_index, std::in_place_t, std::in_place_type_t, std::in_place_index_t
ja.cppreference.net より
| ヘッダ <utility>
|
||
struct in_place_t { explicit in_place_t() = default; };
|
で定義 (1) | (C++17以上) |
inline constexpr std::in_place_t in_place {};
|
(2) | (C++17以上) |
template< class T >
struct in_place_type_t { explicit in_place_type_t() = default; };
|
(3) | (C++17以上) |
template< class T >
constexpr std::in_place_type_t<T> in_place_type {};
|
(4) | (C++17以上) |
template< std::size_t I >
struct in_place_index_t { explicit in_place_index_t() = default; };
|
(5) | (C++17以上) |
template< std::size_t I >
constexpr std::in_place_index_t<I> in_place_index {};
|
(6) | (C++17以上) |
1,3,5) 型/型テンプレート
std::in_place_t、std::in_place_type_t および std::in_place_index_t は、コンストラクタのパラメータリストで使用して、意図するタグと一致させることができます。2,4,6) 対応する
std::in_place、std::in_place_type、および std::in_place_index のインスタンス (1,3,5) は、包含オブジェクトをインプレースで構築する必要があること、および(後者の2つについては)構築するオブジェクトの型を示すためにコンストラクタに渡すことができる明確化タグです。標準ライブラリ
以下の標準ライブラリ型は (1-6) を曖昧性除去タグとして使用します:
|
(C++17)
|
任意の
CopyConstructible
型のインスタンスを保持するオブジェクト
(クラス) |
|
(C++23)
|
期待値またはエラー値のいずれかを含むラッパー
(クラステンプレート) |
|
(C++23)
|
特定の呼び出しシグネチャにおける修飾子をサポートする任意の呼び出し可能オブジェクトのムーブ専用ラッパー
(クラステンプレート) |
|
(C++17)
|
オブジェクトを保持する場合と保持しない場合があるラッパー
(クラステンプレート) |
|
(C++17)
|
型安全な判別共用体
(クラステンプレート) |
関連項目
|
(C++23)
|
範囲の要素がソート済みで一意であることを示す
(タグ) |
|
範囲の要素がソート済みであることを示す(一意性は不要)
(タグ) |