Copy constructor with smart pointer
问题 I have a class with one std::unique_ptr as class member. I was wondering, how to correctly define the copy constructor, since I'm getting the following compiler error message: error C2248: std::unique_ptr<_Ty>::unique_ptr : cannot access private member declared in class 'std::unique_ptr<_Ty> . My class design looks something like: template <typename T> class Foo{ public: Foo(){}; Foo( Bar<T> *, int ); Foo( const Foo<T> & ); ~Foo(){}; void swap( Foo<T> & ); Foo<T> operator = ( Foo<T> );