fork download
  1. struct A {
  2. int a;
  3. };
  4.  
  5. bool operator>(A& a, const int& inty) { return a.a > inty; }
  6.  
  7. // this next one doesn't compile
  8. template <class A, class B> auto operator<(const A& a, const B& b) -> decltype(operator>(a,b)) { return a < b; }
  9.  
  10. // this next one does
  11. template <class A, class B> auto operator<(const A& a, const B& b) -> decltype(a>b) { return a < b; }
  12.  
  13. int main(void) {
  14. A a; a.a = 1; int b = 2;
  15. //operator<(a,b);
  16. a < b;
  17. return 0;
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:6: error: no match for 'operator<' in 'a < b'
prog.cpp:17:10: error: expected '}' at end of input
stdout
Standard output is empty