fork download
  1. #include <cassert>
  2.  
  3. template <class T>
  4. void foo()
  5. {
  6. }
  7.  
  8. /** Determine whether the 'foo' attribute of an object is negative. */
  9. template <class T>
  10. bool foo_negative(T& v)
  11. {
  12. return v.foo < 0;
  13. }
  14.  
  15. struct X
  16. {
  17. int foo;
  18. };
  19.  
  20. int main()
  21. {
  22. X x;
  23. x.foo = 5;
  24. assert(!foo_negative(x));
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘bool foo_negative(T&)’:
prog.cpp:12: error: parse error in template argument list
prog.cpp: In function ‘bool foo_negative(T&) [with T = X]’:
prog.cpp:24:   instantiated from here
prog.cpp:12: error: ‘foo’ is not a member template function
stdout

Standard output is empty