std::piecewise_construct
提供: cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
| ヘッダ <utility> で定義
|
||
constexpr std::piecewise_construct_t piecewise_construct{}; |
(C++11以上) (C++17未満) |
|
inline constexpr std::piecewise_construct_t piecewise_construct{}; |
(C++17以上) | |
定数 std::piecewise_construct は空の構造体のタグ型 std::piecewise_construct_t のインスタンスです。
例
Run this code
#include <iostream>
#include <utility>
#include <tuple>
struct Foo {
Foo(std::tuple<int, float>)
{
std::cout << "Constructed a Foo from a tuple\n";
}
Foo(int, float)
{
std::cout << "Constructed a Foo from an int and a float\n";
}
};
int main()
{
std::tuple<int, float> t(1, 3.14);
std::pair<Foo, Foo> p1(t, t);
std::pair<Foo, Foo> p2(std::piecewise_construct, t, t);
}
出力:
Constructed a Foo from a tuple
Constructed a Foo from a tuple
Constructed a Foo from an int and a float
Constructed a Foo from an int and a float
関連項目
(C++11) |
区分的構築用の関数オーバーロードを正しく選択するために使用されるタグ型 (クラス) |
| 新しいペアを構築します ( std::pair<T1,T2>のパブリックメンバ関数)
|