It sounds like you have a bad design issue in your code more than anything else. First off, why would you want to create a shared_ptr*
? That already seems wrong.
Then leaking it because you don’t know when other threads will be finished with it? What?? That’s bad.
Why not just have two shared_ptr
and use them properly? Maybe that will make your life much easier.
Also, NO, you cannot get the shared_ptr*
to delete itself with the destructor of the object it owns. That would probably get into an unbreakable cycle. Because the shared_ptr is trying to delete the object it owns, and then that will try to delete the owner, which in turn…. You get the idea… That is silly.
3
solved Can a dynamically allocated shared_ptr delete itself via the dtor of the object it’s managing?