fork(8) download
  1. #include <iostream>
  2.  
  3. struct X
  4. {
  5. int a;
  6. friend bool operator<(const X& left, const X& right) { return left.a < right.a; }
  7. private:
  8. struct safe_zero_idiom;
  9. public:
  10. friend bool operator<(const X& left, safe_zero_idiom*) { return left.a < 0; }
  11. };
  12.  
  13. int main()
  14. {
  15. X x{1}, y{-2};
  16. //if (x < 3)
  17. std::cout << (y < x) << "\n";
  18. std::cout << (y < 0) << "\n";
  19. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1
1