fork(6) download
  1. #include <type_traits>
  2.  
  3. template<class T>
  4. struct trait{ using type = typename T::type; };
  5.  
  6. template<class T, class U = typename trait<T>::type>
  7. void f(int);
  8. void f(...);
  9.  
  10. template<class T, class U = typename T::type>
  11. void g(int);
  12. void g(...);
  13.  
  14. template<class>
  15. struct dependent_false : std::false_type{};
  16.  
  17. template<class T>
  18. struct X{
  19. static_assert(dependent_false<T>(), "...");
  20. using type = void;
  21. };
  22.  
  23. int main(){
  24. f<int>(0);
  25. g<X<int>>(0);
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘struct trait<int>’:
prog.cpp:6:19:   required from here
prog.cpp:4:44: error: ‘int’ is not a class, struct, or union type
prog.cpp: In function ‘int main()’:
prog.cpp:24:13: error: no matching function for call to ‘f(int)’
prog.cpp:24:13: note: candidate is:
prog.cpp:7:6: note: template<class T, class U> void f(int)
prog.cpp:7:6: note:   substitution of deduced template arguments resulted in errors seen above
prog.cpp: In instantiation of ‘struct X<int>’:
prog.cpp:10:19:   required from here
prog.cpp:19:5: error: static assertion failed: ...
stdout
Standard output is empty