I know it's unwise to do so with a std::shared_ptr. But what about std::unique_ptr? E.g. :
std::shared_ptr
std::unique_ptr
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