// main.cpp #include"bar.h" intmain(){ Bar bar = Bar(); return0; }
するとコンパイルエラーが出る:
$ g++ -c main.cpp main.cpp:4:7: error: call to implicitly-deleted copy constructor of 'Bar' Bar bar = Bar(); ^ ~~~~~ ./bar.h:13:24: note: copy constructor of 'Bar' is implicitly deleted because field 'foo' has a deleted copy constructor std::unique_ptr<Foo> foo; ^ include/c++/v1/memory:2621:31: note: copy constructor is implicitly deleted because 'unique_ptr<Foo, std::__1::default_delete<Foo> >' has a user-declared move constructor _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT ^ 1 error generated.