fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. template<typename T>
  7. void foo(const T &arg)
  8. {
  9. static_assert(std::is_same<T, int>::value, "int requeired");
  10. }
  11.  
  12. struct C {};
  13.  
  14. int main() {
  15. int a;
  16. foo(a);
  17.  
  18. C c;
  19. foo(c);
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'void foo(const T&) [with T = C]':
prog.cpp:19:7:   required from here
prog.cpp:9:2: error: static assertion failed: int requeired
  static_assert(std::is_same<T, int>::value, "int requeired");
  ^
stdout
Standard output is empty