fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename HEAD, typename... TAIL>
  5. struct List
  6. {
  7. void f(HEAD head, TAIL... tail) {
  8. cout << head << endl;
  9. List<TAIL...> ls;
  10. ls.f(tail...);
  11. }
  12. };
  13. template <>
  14. struct List<>
  15. {
  16. void f() {}
  17. };
  18.  
  19. int main()
  20. {
  21. List<int, double, char> ls;
  22. ls.f(1, 3.14, 'a');
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 15232KB
stdin
Standard input is empty
compilation info
prog.cpp:14:13: error: wrong number of template arguments (0, should be at least 1)
 struct List<>
             ^
prog.cpp:5:8: note: provided for ‘template<class HEAD, class ... TAIL> struct List’
 struct List
        ^~~~
prog.cpp: In instantiation of ‘void List<HEAD, TAIL>::f(HEAD, TAIL ...) [with HEAD = char; TAIL = {}]’:
prog.cpp:10:3:   recursively required from ‘void List<HEAD, TAIL>::f(HEAD, TAIL ...) [with HEAD = double; TAIL = {char}]’
prog.cpp:10:3:   required from ‘void List<HEAD, TAIL>::f(HEAD, TAIL ...) [with HEAD = int; TAIL = {double, char}]’
prog.cpp:22:19:   required from here
prog.cpp:9:17: error: wrong number of template arguments (0, should be at least 1)
   List<TAIL...> ls;
                 ^~
prog.cpp:5:8: note: provided for ‘template<class HEAD, class ... TAIL> struct List’
 struct List
        ^~~~
prog.cpp:9:17: error: wrong number of template arguments (0, should be at least 1)
   List<TAIL...> ls;
                 ^~
prog.cpp:5:8: note: provided for ‘template<class HEAD, class ... TAIL> struct List’
 struct List
        ^~~~
stdout
Standard output is empty