fork(3) download
  1. #include <type_traits>
  2.  
  3. template <int N>
  4. struct test {
  5. void foo() {}
  6.  
  7. typename std::enable_if<N == 2>::type bar() {}
  8.  
  9. template <int P=N>
  10. typename std::enable_if<P == 3 && P == N>::type baz() {}
  11. };
  12.  
  13. int main() {
  14. test<1> a = {};
  15. test<2> b = {};
  16. test<3> c = {};
  17.  
  18. a.foo();
  19. b.foo();
  20. c.foo();
  21.  
  22. b.bar();
  23. c.baz();
  24.  
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘struct test<1>’:
prog.cpp:14:11:   required from here
prog.cpp:7:41: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
   typename std::enable_if<N == 2>::type bar() {}
                                         ^
prog.cpp: In instantiation of ‘struct test<3>’:
prog.cpp:16:11:   required from here
prog.cpp:7:41: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
stdout
Standard output is empty