fork(2) download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. struct A
  5. {
  6. A() {}
  7. A(A && other)
  8. {
  9. std::cout << "moved (using move-constructor) " << std::endl;
  10. }
  11. A& operator=(A && other)
  12. {
  13. std::cout << "moved (using move-assignment) " << std::endl;
  14. return *this;
  15. }
  16. A(A const & other)
  17. {
  18. std::cout << "copied (using copy-constructor) " << std::endl;
  19. }
  20. A& operator=(A const & other)
  21. {
  22. std::cout << "copied (using copy-assignment) " << std::endl;
  23. return *this;
  24. }
  25. };
  26.  
  27. struct B
  28. {
  29. A a;
  30. B() {}
  31. };
  32.  
  33. int main()
  34. {
  35. B b1,b2;
  36. b1 = std::move(b1);
  37. }
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
copied (using copy-assignment)