fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. int a;
  6. };
  7.  
  8. template<typename, typename = void>
  9. struct test
  10. {};
  11.  
  12. template<typename T>
  13. struct test<T, decltype(T::a)>
  14. {};
  15.  
  16. int main()
  17. {
  18. test<A> a;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:13:29: error: a function call cannot appear in a constant-expression
 struct test<T, decltype(T::a)>
                             ^
prog.cpp:13:30: error: template argument 2 is invalid
 struct test<T, decltype(T::a)>
                              ^
stdout
Standard output is empty