fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct RAII {
  5. int n;
  6. RAII(int n) : n(n) { std::cout << "ctor " << n << '\n'; }
  7. RAII(RAII &&x) { n = x.n; x.n = -1; std::cout << "move " << n << '\n'; }
  8. ~RAII() { std::cout << "dtor " << n << '\n'; }
  9. };
  10.  
  11. int main() {
  12. RAII x(1);
  13. RAII *y = new RAII(std::move(x));
  14. return 0;
  15. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
ctor 1
move 1
dtor -1