#include <iostream>#include <type_traits> using namespace std; template<typename T>void foo(const T &arg){ static_assert(std::is_same<T, int>::value, "int requeired");} struct C {}; int main() { int a; foo(a); C c; foo(c); return 0;}
Standard input is empty
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"); ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!