fork download
  1. template <typename...>
  2. struct Seq;
  3.  
  4. template <typename>
  5. struct always_false
  6. {
  7. static constexpr bool value = false;
  8. };
  9.  
  10. template <typename, typename = void>
  11. struct car;
  12.  
  13. template <typename head, typename... tail, typename dummy>
  14. struct car<Seq<head, tail...>, dummy>
  15. {
  16. typedef head type;
  17. };
  18.  
  19. template <typename dummy>
  20. struct car<Seq<>, dummy>
  21. {
  22. static_assert(always_false<dummy>::value, "car of empty Seq");
  23. };
  24.  
  25. #include <iostream>
  26. #include <typeinfo>
  27.  
  28. int main()
  29. {
  30. car<Seq<>> error;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘struct car<Seq<> >’:
prog.cpp:30:13:   required from here
prog.cpp:22:2: error: static assertion failed: car of empty Seq
  static_assert(always_false<dummy>::value, "car of empty Seq");
  ^
prog.cpp: In function ‘int main()’:
prog.cpp:30:13: warning: unused variable ‘error’ [-Wunused-variable]
  car<Seq<>> error;
             ^
stdout
Standard output is empty