fork download
  1. #include <utility>
  2. #include <tuple>
  3.  
  4. template<typename T, T ...I>
  5. auto ignore_n(std::integer_sequence<T, I...>) {
  6. return std::make_tuple((I, std::ignore)...);
  7. }
  8.  
  9. template<typename... Ts>
  10. auto function(Ts... ts)
  11. -> decltype((std::tuple_cat(
  12. ignore_n(std::make_index_sequence<sizeof(char[int(sizeof...(Ts))-1])-1>()),
  13. std::tuple<double, bool>()) = std::forward_as_tuple(ts...)), void())
  14. {
  15.  
  16. }
  17.  
  18. int main() {
  19. function(2);
  20. function(1, 2, 3);
  21. function(1, 2, 3, 4);
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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.
stdout
Standard output is empty