I'm constructing an object that takes a std::vector<std::unique_ptr<A> >
as an argument. The constructor is defined like this
class B {
std::vector <std::unique_ptr<A> > e_;
public:
B(std::vector <std::unique_ptr<A> > e) : e_(std::move(e)){}
};
and then used as
std::vector <std::unique_ptr<A> > e;
B b(e);
and Xcode presents the error
error: call to implicitly-deleted copy constructor of 'std::__1::unique_ptr<A, std::__1::default_delete<A> >'
:new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Why is the error still persisting even though i am using std::move()
?
EDIT: the error seems to vanish if i use B b(std::move(e))
instead of B b(e))
, is there any way to move the move
logic to the implementation of the function?
Aucun commentaire:
Enregistrer un commentaire