fork download
  1. #include <memory>
  2. using namespace std;
  3. class foo
  4. {
  5. public:
  6. unique_ptr<int> p;
  7. ~foo()
  8. {
  9.  
  10. }
  11. };
  12. int main()
  13. {
  14. foo a, b;
  15. a = move(b);
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:15:4: error: use of deleted function 'foo& foo::operator=(const foo&)'
  a = move(b);
    ^
prog.cpp:3:7: note: 'foo& foo::operator=(const foo&)' is implicitly deleted because the default definition would be ill-formed:
 class foo
       ^
prog.cpp:3:7: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = int; _Dp = std::default_delete<int>]'
In file included from /usr/include/c++/5/memory:81:0,
                 from prog.cpp:1:
/usr/include/c++/5/bits/unique_ptr.h:357:19: note: declared here
       unique_ptr& operator=(const unique_ptr&) = delete;
                   ^
stdout
Standard output is empty