Skip to content

Instantly share code, notes, and snippets.

@sdmg15
Created February 11, 2022 09:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#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