#include <functional>
#include <iostream>
#include <string>
#include <tuple>
using namespace std;
template <typename... Tp, size_t begin = 0U>
enable_if_t<begin == sizeof...(Tp), void> foo(tuple<Tp...>& t){
cout << endl;
}
template <typename... Tp, size_t begin = 0U>
enable_if_t<begin < sizeof...(Tp), void> foo(tuple<Tp...>& t) {
cout << get<begin>(t) << ' ';
foo<Tp..., begin + 1>(t);
}
int main() {
tuple<int, string, float> t = make_tuple(42, "Jonathan Mee", 13.13);
foo(t);
}
I2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHR1cGxlPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGUgPHR5cGVuYW1lLi4uIFRwLCBzaXplX3QgYmVnaW4gPSAwVT4KZW5hYmxlX2lmX3Q8YmVnaW4gPT0gc2l6ZW9mLi4uKFRwKSwgdm9pZD4gZm9vKHR1cGxlPFRwLi4uPiYgdCl7Cgljb3V0IDw8IGVuZGw7Cn0KCnRlbXBsYXRlIDx0eXBlbmFtZS4uLiBUcCwgc2l6ZV90IGJlZ2luID0gMFU+CmVuYWJsZV9pZl90PGJlZ2luIDwgc2l6ZW9mLi4uKFRwKSwgdm9pZD4gZm9vKHR1cGxlPFRwLi4uPiYgdCkgewoJY291dCA8PCBnZXQ8YmVnaW4+KHQpIDw8ICcgJzsKCWZvbzxUcC4uLiwgYmVnaW4gKyAxPih0KTsKfQoKaW50IG1haW4oKSB7Cgl0dXBsZTxpbnQsIHN0cmluZywgZmxvYXQ+IHQgPSBtYWtlX3R1cGxlKDQyLCAiSm9uYXRoYW4gTWVlIiwgMTMuMTMpOwoKCWZvbyh0KTsKfQ==
prog.cpp: In instantiation of 'std::enable_if_t<(begin < sizeof... (Tp)), void> foo(std::tuple<_Elements ...>&) [with Tp = {int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, float}; unsigned int begin = 0u; std::enable_if_t<(begin < sizeof... (Tp)), void> = void]':
prog.cpp:21:7: required from here
prog.cpp:15:23: error: no matching function for call to 'foo(std::tuple<int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, float>&)'
foo<Tp..., begin + 1>(t);
^
prog.cpp:8:43: note: candidate: template<class ... Tp, unsigned int begin> std::enable_if_t<(begin == sizeof... (Tp)), void> foo(std::tuple<_Elements ...>&)
enable_if_t<begin == sizeof...(Tp), void> foo(tuple<Tp...>& t){
^
prog.cpp:8:43: note: template argument deduction/substitution failed:
prog.cpp:13:42: note: candidate: template<class ... Tp, unsigned int begin> std::enable_if_t<(begin < sizeof... (Tp)), void> foo(std::tuple<_Elements ...>&)
enable_if_t<begin < sizeof...(Tp), void> foo(tuple<Tp...>& t) {
^
prog.cpp:13:42: note: template argument deduction/substitution failed: