std::piecewise_construct - cppreference.com
提供: cppreference.com
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
| ヘッダ |
||
|
|
(C++11以上) (C++17未満) |
|
|
|
(C++17以上) | |
定数 std::piecewise_construct は空の構造体のタグ型 std::piecewise_construct_t のインスタンスです。
例
#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