#include <iostream> class A{};class B : A{};class C{}; template <typename T>void f (T t) { static_assert ( std::is_same<T, A>::value || std::is_base_of<A, T>::value, "Type must be either A or derived from A." ); std::cout << "Yay";} int main() { A a; B b; C c; f(c);}
Standard input is empty
prog.cpp: In function 'void f(T) [with T = C]': prog.cpp:21:8: instantiated from here prog.cpp:9:5: error: static assertion failed: "Type must be either A or derived from A."
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!