fork download
  1. #include <iostream>
  2. #define P(x) std::cout<<x<<std::endl
  3.  
  4. struct Yoba
  5. {
  6. int* data;
  7. Yoba() { P("new"); data=new int[10]; }
  8. Yoba(const Yoba & copy) :Yoba() { P("copy");}
  9. Yoba(Yoba && move) :Yoba() { P("move"); std::swap(this->data,move.data);}
  10. ~Yoba() { P("del"); delete [] data;}
  11. };
  12.  
  13. int main()
  14. {
  15. Yoba a;
  16. Yoba b = std::move(a);
  17. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
new
new
move
del
del