fork(12) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Foo {
  5. public:
  6. Foo() = default;
  7. Foo(Foo const &) = delete;
  8. Foo(Foo &&) { std::cout << "Move"; }
  9. };
  10.  
  11. Foo F1() {
  12. Foo f;
  13. return f;
  14. }
  15.  
  16. Foo F2(bool b) {
  17. Foo f1;
  18. Foo f2;
  19. if (b) return f1;
  20. else return f2;
  21. }
  22.  
  23. int main() {
  24. std::cout << "Calling F1: ";
  25. F1();
  26. std::cout << "\n";
  27.  
  28. std::cout << "Calling F2: ";
  29. F2(true);
  30. std::cout << "\n";
  31. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Calling F1: 
Calling F2: Move