fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. class Base {};
  5. class Derived : Base {};
  6. class NotDerived {};
  7.  
  8.  
  9. template <typename T>
  10. class foo;
  11.  
  12. template <typename T>
  13. class foo<T*>
  14. {
  15. static_assert(std::is_base_of<Base, T>::value, "Type is not a pointer to type derived from Base");
  16. };
  17.  
  18. int main(int argc, const char* argv[])
  19. {
  20. foo<Base*> f1;
  21. foo<Derived*> f2;
  22. // foo<NotDerived*> f3; // Won't compile
  23. return 0;
  24. }
Success #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout
Standard output is empty