c++ for each item in tuple code example
Example 1: iterator on std::tuple
#include <tuple>
#include <iostream>
int main()
{
std::tuple t{42, 'a', 4.2}; // Another C++17 feature: class template argument deduction
std::apply([](auto&&... args) {((std::cout << args << '\n'), ...);}, t);
}
Example 2: iterator on std::tuple
std::apply([](auto ...x){std::make_tuple(x.do_something()...);} , the_tuple);