How do I use a variable to index into a tuple using std::get<>? I have the following code:
#include
#include
using n
Any idea how to make that work?
Use compile time constants to access the std::tuple
.
cout << "#" << 1 << ":" << get<0>(data) << endl;
cout << "#" << 2 << ":" << get<1>(data) << endl;
Use a container type whose elements can be accessed using an index at run time.
std::vector data{5, 10};
or
std::array data{5, 10};