fork(2) download
  1. #include <iostream>
  2.  
  3. struct cool_operator
  4. {
  5. cool_operator() = default;
  6. cool_operator(int _n, bool b = false) : first(b), n(_n) {}
  7.  
  8. bool first;
  9.  
  10. bool operator <(int x) const
  11. {
  12. return first && (n < x);
  13. }
  14.  
  15. int n;
  16. };
  17.  
  18. cool_operator operator <(int x, cool_operator const &lhs)
  19. {
  20. return cool_operator(lhs.n, x < lhs.n);
  21. }
  22.  
  23. int main()
  24. {
  25. cool_operator c(4);
  26.  
  27. std::cout << std::boolalpha << (3 < c < 5); // true
  28. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
true