fork(2) download
  1. template <class T>
  2. auto f(T v) -> decltype(g(v));
  3.  
  4. int g(int) { return 0; }
  5.  
  6. template <class T>
  7. auto f(T v) -> decltype(g(v))
  8. {
  9. return g(v) + 1;
  10. }
  11.  
  12. int main()
  13. {
  14. return f(0);
  15. }
  16.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:14:13: error: no matching function for call to 'f(int)'
   return f(0);
             ^
prog.cpp:7:6: note: candidate: template<class T> decltype (g(v)) f(T)
 auto f(T v) -> decltype(g(v))
      ^
prog.cpp:7:6: note:   template argument deduction/substitution failed:
prog.cpp: In substitution of 'template<class T> decltype (g(v)) f(T) [with T = int]':
prog.cpp:14:13:   required from here
prog.cpp:2:26: error: 'g' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
 auto f(T v) -> decltype(g(v));
                          ^
prog.cpp:4:5: note: 'int g(int)' declared here, later in the translation unit
 int g(int) { return 0; }
     ^
stdout
Standard output is empty