fork download
  1. #include <iostream>
  2.  
  3. // Source - https://stackoverflow.com/a/10616756
  4. // Posted by Jon, modified by community. See post 'Timeline' for change history
  5. // Retrieved 2025-12-12, License - CC BY-SA 3.0
  6.  
  7. #define OUT(x) if((x > 0 ? cout << "Hello " : cout), x > 1) cout << x+1
  8.  
  9.  
  10. using namespace std;
  11.  
  12. int main() {
  13. OUT(1) << "message"; // OK
  14.  
  15. if(0) {
  16. OUT(1) << "message"; // OK, nothing printed
  17. }
  18.  
  19. if(0)
  20. OUT(1) << "message"; // Now nothing is printed
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Hello