According to the first answer in this article: Explicitly deleting a shared_ptr
Is it possible to force delete a std::shared_ptr and the object it manages like below code?
do {
ptr.reset();
} while (!ptr.unique());
ptr.reset(); // To eliminate the last reference
Technically, this should try calling std::shared_ptr::reset
if the pointer has more than 1 reference count, unless it reaches to one. Any thoughts on this?
Aucun commentaire:
Enregistrer un commentaire