fork download
  1. #include <iostream>
  2.  
  3. class Test
  4. {
  5. public:
  6.  
  7. Test()
  8. { std::cout << "Test::Test()" << std::endl; }
  9.  
  10. Test (const Test& rhs)
  11. { std::cout << "Test::Test (const Test&)" << std::endl; }
  12.  
  13. Test (Test&& rhs)
  14. { std::cout << "Test::Test (Test&&)" << std::endl; }
  15.  
  16. Test& operator= (const Test& rhs)
  17. { std::cout << "Test::operator= (const Test&)" << std::endl; return *this; }
  18.  
  19. Test& operator= (Test&& rhs)
  20. { std::cout << "Test::operator= (Test&&)" << std::endl; return *this; }
  21. };
  22.  
  23. Test immediate_return()
  24. {
  25. return Test();
  26. }
  27.  
  28. Test local_variable()
  29. {
  30. Test local;
  31. return local;
  32. }
  33.  
  34. Test local_variable_and_assignment()
  35. {
  36. Test local = Test();
  37. return local;
  38. }
  39.  
  40. int main()
  41. {
  42. Test a;
  43. Test b = Test();
  44. Test c = immediate_return();
  45. Test d = local_variable();
  46. Test e = local_variable_and_assignment();
  47. return 0;
  48. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Test::Test()
Test::Test()
Test::Test()
Test::Test()
Test::Test()