std::piecewise_construct
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
constexpr piecewise_construct_t piecewise_construct = std::piecewise_construct_t(); |
(C++11 起) | |
的不断std::piecewise_construct的一个实例,一个空的结构标签类型std::piecewise_construct_t
原文:
The constant std::piecewise_construct is an instance of an empty struct tag type 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
[编辑] 另请参阅
(C++11) |
使用的标签类型选择正确的重载函数,分段建设 原文: tag type used to select correct function overload for piecewise construction (类) |