Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- template<typename T>
- void print(T&& val) {
- cout << val << endl;
- }
- template<typename T, typename... Args>
- void print(T&& val, Args&&... args) {
- cout << val;
- print(args...);
- }
- template<typename Tuple, size_t... I>
- void print_tuple_impl(Tuple&& tup, /* THIS IS A BLOODY TYPE and will be unpacked! */ index_sequence<I...>) {
- print(get<I>(tup)...);
- }
- template<typename Tuple>
- void print_tuple(Tuple&& tup) {
- using Indices = index_sequence<0, 2>;
- /* Indices type allows to deduce size_t... in print_tuple_impl */
- print_tuple_impl(tup, Indices{});
- }
- int main() {
- auto tup = make_tuple(5, 4.0, 13);
- print_tuple(tup);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement