Skip to content

Instantly share code, notes, and snippets.

@sdmg15
Created February 11, 2022 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdmg15/0ed6f94cdab1cb8287a070e1b6dbf551 to your computer and use it in GitHub Desktop.
Save sdmg15/0ed6f94cdab1cb8287a070e1b6dbf551 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <utility>
#include <tuple>
template<typename T>
void printWithSpace(T v) {
std::cout << v << " ";
}
template<std::size_t... I, typename Tup>
void printTuple(std::index_sequence<I...> seq, Tup t){
(..., printWithSpace(std::get<I>(t)));
}
auto main() -> int {
std::tuple<int, std::string , double> my{10, "yo", 13.13};
constexpr std::size_t t_size = std::tuple_size_v<decltype(my)>;
printTuple(std::make_index_sequence<t_size>(), my);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment