fork download
  1.  
  2. #include <type_traits>
  3.  
  4. template <typename> struct never_true : std::false_type { };
  5.  
  6. template <typename T> struct Foo
  7. {
  8. static_assert(never_true<T>::value, "Can't use this.");
  9. };
  10.  
  11. struct Bar;
  12.  
  13. int main()
  14. {
  15. Foo<Bar> x;
  16. Foo<int> y;
  17. Foo<int[]> z;
  18. }
  19.  
  20.  
  21.  
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘struct Foo<Bar>’:
prog.cpp:15:16:   required from here
prog.cpp:8:5: error: static assertion failed: Can't use this.
prog.cpp: In instantiation of ‘struct Foo<int>’:
prog.cpp:16:16:   required from here
prog.cpp:8:5: error: static assertion failed: Can't use this.
prog.cpp: In instantiation of ‘struct Foo<int []>’:
prog.cpp:17:16:   required from here
prog.cpp:8:5: error: static assertion failed: Can't use this.
prog.cpp: In function ‘int main()’:
prog.cpp:15:16: warning: unused variable ‘x’ [-Wunused-variable]
prog.cpp:16:16: warning: unused variable ‘y’ [-Wunused-variable]
prog.cpp:17:16: warning: unused variable ‘z’ [-Wunused-variable]
stdout
Standard output is empty