get first element of tuple c 2b 2b

Solutions on MaxInterview for get first element of tuple c 2b 2b by the best coders in the world

showing results for - "get first element of tuple c 2b 2b"
Mads
26 Feb 2017
1#include <iostream>
2#include <string>
3#include <tuple>
4 
5auto t = std::make_tuple(1, "Foo", 3.14);
6// index-based access
7std::cout << "(" << std::get<0>(t) << ", " << std::get<1>(t)<< ", " << std::get<2>(t) << ")\n";
8// type-based access (C++14 or later)
9std::cout << "(" << std::get<int>(t) << ", " << std::get<const char*>(t) << ", " << std::get<double>(t) << ")\n";
10