fork(2) download
  1. #include <iostream>
  2.  
  3. struct s1
  4. {
  5. s1() {}
  6. s1(const s1&& other) { std::cout << "moved s1\n"; }
  7. s1(const s1& other) { std::cout << "copied s1\n"; }
  8. };
  9.  
  10. struct s2
  11. {
  12. s2() {}
  13. s2(s2&& other) { std::cout << "moved s2\n"; }
  14.  
  15. s2(const s2& other) { std::cout << "copied s2\n"; }
  16. };
  17.  
  18.  
  19. s1 f1()
  20. {
  21. const s1 r;
  22. return std::move(r);
  23. }
  24.  
  25. s2 f2()
  26. {
  27. const s2 r;
  28. return std::move(r);
  29. }
  30.  
  31. int main()
  32. {
  33. std::cout << "hello\n";
  34. s1 v1= f1();
  35. s2 v2 = f2();
  36. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
hello
moved s1
copied s2