std::get与std::make_tuple

int main()
{
auto t = std::make_tuple(1, “Foo”, 3.14);
// index-based access
std::cout << “(” << std::get<0>(t) << ", " << std::get<1>(t)
<< ", " << std::get<2>(t) << “)\n”;
// type-based access
std::cout << “(” << std::get(t) << ", " << std::get<const char*>(t)
<< ", " << std::get(t) << “)\n”;
// Note: std::tie and structured binding may also be used to decompose a tuple
}
Output:

(1, Foo, 3.14)
(1, Foo, 3.14)

猜你喜欢

转载自blog.csdn.net/weixin_37597675/article/details/89155992
std