Created
February 11, 2022 09:29
-
-
Save sdmg15/0ed6f94cdab1cb8287a070e1b6dbf551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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