fork download
  1. #include <memory>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. struct MyClass {
  6. void SetThing(bool x, bool y) {
  7. cout << "this == " << this << endl;
  8. if (x && !y) {
  9. cout << "Skipping SetThing() because x == true and y == false" << endl;
  10. return;
  11. }
  12. value = 42;
  13. }
  14.  
  15. int value{};
  16. };
  17.  
  18. int main() {
  19. unique_ptr<MyClass> c;
  20. c->SetThing(true, false);
  21. cout << "Thank you, segfault catchers in testing, very cool!" << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5260KB
stdin
Standard input is empty
stdout
this == 0
Skipping SetThing() because x == true and y == false
Thank you, segfault catchers in testing, very cool!