fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define EVALUATE_AND_PRINT(EXPR) \
  5. cout << "\"" #EXPR "\" is evaluated to "; print(EXPR); cout << endl;
  6.  
  7. void print(int v){ cout << "(int)" << v; }
  8. void print(bool v){ cout << "(bool)" << v; }
  9.  
  10. int main() {
  11. cout << showbase << hex << boolalpha;
  12.  
  13. bool b;
  14. EVALUATE_AND_PRINT(b = true);
  15. EVALUATE_AND_PRINT(~b);
  16. EVALUATE_AND_PRINT(b = ~b);
  17. return 0;
  18. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
"b = true" is evaluated to (bool)true
"~b" is evaluated to (int)0xfffffffe
"b = ~b" is evaluated to (bool)true