fork download
  1. #include <iostream>
  2.  
  3. using std::cerr;
  4.  
  5. class A
  6. {
  7. public:
  8. A() { cerr << "A::A()\n"; }
  9. A(const A &) { cerr << "A::A(const A&)\n"; }
  10. A(A &&) { cerr << "A::A(A&&)\n"; }
  11. A(const A &&) = delete;
  12. A & operator = (const A &) { cerr << "A::operator=(const A&)\n"; return *this; }
  13. A & operator = (A &&) { cerr << "A::operator(A&&)\n"; return *this; }
  14. A & operator = (const A &&) = delete;
  15. ~A() { cerr << "A::~A()\n"; }
  16.  
  17. const A get() const { cerr << "const A A::get() const\n"; return A(); }
  18. A get() { cerr << "A A::get()\n"; return A(); }
  19. };
  20.  
  21. int main()
  22. {
  23. const A a;
  24. A b = a.get();
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:24:17: error: use of deleted function 'A::A(const A&&)'
     A b = a.get();
                 ^
prog.cpp:11:5: note: declared here
     A(const A &&) = delete;
     ^
stdout
Standard output is empty