fork(1) download
  1. #include <iostream>
  2.  
  3.  
  4. template <int... Ints>
  5. struct IntList;
  6.  
  7. template <int H, int... T>
  8. struct IntList<H, T...>
  9. {
  10. static const int Head = H;
  11. using Tail = IntList<T...>;
  12. };
  13.  
  14. template<>
  15. struct IntList<> {};
  16.  
  17. template <typename IL>
  18. struct ILength
  19. {
  20. static const int value = 1 + ILength<typename IL::Tail>::value;
  21. };
  22.  
  23. template <>
  24. struct ILength<IntList<>>
  25. {
  26. static const int value = 0;
  27. };
  28.  
  29. template <int Head, int... Tail>
  30. struct ICons;
  31.  
  32. template <int Head, int... Tail>
  33. struct ICons<Head, IntList<Tail...>>
  34. {
  35. using type = IntList<Head, Tail...>;
  36. };
  37.  
  38. /*
  39. template <int Head, typename... Tail>
  40. struct ICons;
  41.  
  42. template <int Head, typename... Tail>
  43. struct ICons<Head, IntList<Tail...>>
  44. {
  45. using type = IntList<Head, Tail...>;
  46. };
  47. */
  48.  
  49.  
  50. int main()
  51. {
  52. return 0;
  53. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:33:35: error: type/value mismatch at argument 2 in template parameter list for ‘template<int Head, int ...Tail> struct ICons’
 struct ICons<Head, IntList<Tail...>>
                                   ^~
prog.cpp:33:35: note:   expected a constant of type ‘int’, got ‘IntList<T ...>’
stdout
Standard output is empty