fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct T03 {
  5. T03() { std::cout << "T03()" << std::endl; }
  6. T03(const T03&) { std::cout << "T03(const T03&)" << std::endl; }
  7. T03 & operator=(const T03&) { std::cout << "T03 & operator=(const T03&) " << std::endl; return *this; }
  8. ~T03() { std::cout << "~T03()" << std::endl; }
  9. };
  10.  
  11. T03 foo1() {
  12. T03 t;
  13. return t;
  14. }
  15.  
  16.  
  17. T03 foo2() {
  18. T03 t;
  19. return std::move(t);
  20. }
  21.  
  22. int main() {
  23. std::cout << "foo1:" << std::endl;
  24. T03 t1 = foo1();
  25. std::cout << "foo2:" << std::endl;
  26. T03 t2 = foo2();
  27. std::cout << "cleanup:" << std::endl;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
foo1:
T03()
foo2:
T03()
T03(const T03&)
~T03()
cleanup:
~T03()
~T03()