fork download
  1. #include <iostream>
  2.  
  3. struct X
  4. {
  5. explicit operator bool() const { return true; }
  6. ~X() { std::cout << "X destroyed\n"; }
  7. };
  8.  
  9. X f() { return {}; }
  10.  
  11. int main()
  12. {
  13. if (f()) { std::cout << "Inside if block\n"; }
  14. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
X destroyed
Inside if block