#include <utility>
#include <tuple>
template<typename T, T ...I>
auto ignore_n(std::integer_sequence<T, I...>) {
return std::make_tuple((I, std::ignore)...);
}
template<typename... Ts>
auto function(Ts... ts)
-> decltype((std::tuple_cat(
ignore_n(std::make_index_sequence<sizeof(char[int(sizeof...(Ts))-1])-1>()),
std::tuple<double, bool>()) = std::forward_as_tuple(ts...)), void())
{
}
int main() {
function(2);
function(1, 2, 3);
function(1, 2, 3, 4);
}
I2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDx0dXBsZT4KCnRlbXBsYXRlPHR5cGVuYW1lIFQsIFQgLi4uST4KYXV0byBpZ25vcmVfbihzdGQ6OmludGVnZXJfc2VxdWVuY2U8VCwgSS4uLj4pIHsKICAgcmV0dXJuIHN0ZDo6bWFrZV90dXBsZSgoSSwgc3RkOjppZ25vcmUpLi4uKTsKfQoKdGVtcGxhdGU8dHlwZW5hbWUuLi4gVHM+CmF1dG8gZnVuY3Rpb24oVHMuLi4gdHMpCiAgIC0+IGRlY2x0eXBlKChzdGQ6OnR1cGxlX2NhdCgKICAgICAgICAgaWdub3JlX24oc3RkOjptYWtlX2luZGV4X3NlcXVlbmNlPHNpemVvZihjaGFyW2ludChzaXplb2YuLi4oVHMpKS0xXSktMT4oKSksCiAgICAgICAgIHN0ZDo6dHVwbGU8ZG91YmxlLCBib29sPigpKSA9IHN0ZDo6Zm9yd2FyZF9hc190dXBsZSh0cy4uLikpLCB2b2lkKCkpCnsKICAgCn0KCmludCBtYWluKCkgewogICBmdW5jdGlvbigyKTsKICAgZnVuY3Rpb24oMSwgMiwgMyk7CiAgIGZ1bmN0aW9uKDEsIDIsIDMsIDQpOwp9
prog.cpp: In function 'int main()':
prog.cpp:19:14: error: no matching function for call to 'function(int)'
function(2);
^
prog.cpp:10:6: note: candidate: template<class ... Ts> decltype ((std::tuple_cat(ignore_n(typename std::_Make_integer_sequence<unsigned int, sizeof (char[int(sizeof ... (Ts ...)) - 1]) - 1, typename std::_Build_index_tuple<sizeof (char[int(sizeof ... (Ts ...)) - 1]) - 1>::__type>::make_index_sequence()), std::tuple<double, bool>())= std::forward_as_tuple(function::ts ...), void())) function(Ts ...)
auto function(Ts... ts)
^
prog.cpp:10:6: note: template argument deduction/substitution failed:
In file included from prog.cpp:1:0:
/usr/include/c++/5/utility: In instantiation of 'struct std::_Build_index_tuple<4294966399u>':
/usr/include/c++/5/utility:215:69: recursively required from 'struct std::_Build_index_tuple<4294967294u>'
/usr/include/c++/5/utility:215:69: required from 'struct std::_Build_index_tuple<4294967295u>'
/usr/include/c++/5/utility:252:59: required by substitution of 'template<class _Tp, _Tp _Num> using make_integer_sequence = typename std::_Make_integer_sequence<_Tp, _Num>::__type [with _Tp = unsigned int; _Tp _Num = 4294967295u]'
/usr/include/c++/5/utility:260:68: required by substitution of 'template<unsigned int _Num> using make_index_sequence = std::make_integer_sequence<unsigned int, _Num> [with unsigned int _Num = (sizeof (char [0]) + 4294967295u)]'
prog.cpp:12:18: required by substitution of 'template<class ... Ts> decltype ((std::tuple_cat(ignore_n(typename std::_Make_integer_sequence<unsigned int, sizeof (char[int(sizeof ... (Ts ...)) - 1]) - 1, typename std::_Build_index_tuple<sizeof (char[int(sizeof ... (Ts ...)) - 1]) - 1>::__type>::make_index_sequence()), std::tuple<double, bool>())= std::forward_as_tuple(function::ts ...), void())) function(Ts ...) [with Ts = {int}]'
prog.cpp:19:14: required from here
/usr/include/c++/5/utility:215:69: fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)
typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type;
^
compilation terminated.