Detach a pointer from a shared_ptr? [duplicate]
What you’re looking for is a release function; shared_ptr doesn’t have a release function. Per the Boost manual: Q. Why doesn’t shared_ptr provide a release() function? A. shared_ptr cannot give away ownership unless it’s unique() because the other copy will still destroy the object. Consider: shared_ptr<int> a(new int); shared_ptr<int> b(a); // a.use_count() == b.use_count() == … Read more