lundi 1 janvier 2018

Is it safe to init a std::unique_ptr from a local raw pointer?

I know it's unwise to do so with a std::shared_ptr. But what about std::unique_ptr? E.g. :

class A { };

std::vector<std::unique_ptr<A> > uq_ptrs_;
auto p = new A();
uq_ptrs_.push_back(std::unique_ptr<A>(p));

Aucun commentaire:

Enregistrer un commentaire