fork(5) 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.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘A f()’:
prog.cpp:14:14: error: use of deleted function ‘constexpr A::A(const A&)’
       return r;
              ^
prog.cpp:3:12: note: ‘constexpr A::A(const A&)’ is implicitly declared as deleted because ‘A’ declares a move constructor or move assignment operator
     struct A {
            ^
stdout
Standard output is empty