fork(6) download
  1. struct A
  2. {
  3. A() = default;
  4. A(const A&) = default;
  5. A(A&&) = delete;
  6. };
  7.  
  8. A foo(const A& a) { return a; } // (1) success: use of the copy constructor
  9. A foo(A&& a) { return a; } // (2) success: use of the copy constructor
  10. A foo(A a) { return a; } // (3) error: use of deleted function 'A::A(A&&)'
  11. A foo() { A a; return a; } // (4) error: use of deleted function 'A::A(A&&)'
  12.  
  13. int main()
  14. {
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'A foo(A)':
prog.cpp:10:23: error: use of deleted function 'A::A(A&&)'
 A foo(A a)   { return a; }   // (3) error: use of deleted function 'A::A(A&&)'
                       ^
prog.cpp:5:2: note: declared here
  A(A&&) = delete;
  ^
prog.cpp: In function 'A foo()':
prog.cpp:11:26: error: use of deleted function 'A::A(A&&)'
 A foo()    { A a; return a; }  // (4) error: use of deleted function 'A::A(A&&)'
                          ^
prog.cpp:5:2: note: declared here
  A(A&&) = delete;
  ^
stdout
Standard output is empty