fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. public:
  6.  
  7. A* self;
  8.  
  9. A() : self(this) { }
  10. A(const A&) = default;
  11. A(A&&) = default;
  12. };
  13.  
  14. int main() {
  15. cout << boolalpha;
  16.  
  17. A a1;
  18. cout << &a1 << " = " << a1.self << " " << (&a1 == a1.self) << endl;
  19.  
  20. A a2(std::move(a1));
  21. cout << &a2 << " = " << a2.self << " " << (&a2 == a2.self) << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0xff814828 = 0xff814828 true
0xff81482c = 0xff814828 false