fork download
  1. struct A {
  2. int a;
  3. bool operator>(const int& inty) { return a > inty; }
  4. };
  5.  
  6. template <class A, class B> auto operator<(const A& c, const B& b) -> decltype(c>b) { return c < b; }
  7.  
  8. int main(void) {
  9. A a;
  10. a.a = 1;
  11. int b = 2;
  12. if (a < b) std::cout << "hi";
  13. return 0;
  14. }
Compilation error #stdin compilation error #stdout 0s 2828KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:12:11: error: no match for 'operator<' in 'a < b'
prog.cpp:12:14: error: 'cout' is not a member of 'std'
stdout
Standard output is empty