fork(3) download
  1. #include <iostream>
  2.  
  3. class IntComp {
  4. public:
  5. IntComp(int x, bool result = true) : value(x), result(result) {}
  6. IntComp operator <= (int x) const
  7. {
  8. return IntComp(x, result && value <= x);
  9. }
  10. IntComp operator > (int x) const
  11. {
  12. return IntComp(x, result && value > x);
  13. }
  14. operator bool() const { return result; }
  15. private:
  16. int value;
  17. bool result;
  18. };
  19.  
  20. int main() {
  21. int x = 134, y = 14;
  22. if (IntComp(7) <= x <= 134)
  23. {
  24. std::cout << "Hello ";
  25. }
  26. if (IntComp(134) > y > 12)
  27. {
  28. std::cout << "world!";
  29. }
  30. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
Hello world!