fork(20) download
  1. #include <iostream>
  2.  
  3. struct A {
  4. const char* name;
  5. A( const char* name_ ):name(name_) { std::cout << "created " << name << "\n"; }
  6. A(A const&){ std::cout << "copied " << name << "\n"; }
  7. A(A &&){ std::cout << "moved " << name << "\n"; }
  8. };
  9.  
  10. A f() {
  11. std::cout << "start of f()\n";
  12. A const r("bob");
  13. std::cout << "body of f()\n";
  14. return r;
  15. }
  16.  
  17. int main() {
  18. A x = f();
  19. }
  20.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
start of f()
created bob
body of f()