Potential memory issues using _Reset()


Hi All,

More of an implementation question… if i have a class with a create() method that creates a shared_ptr, eg.

SomeClassRef myObj = SomeClass::create();

Instead of having a reset() member function that reinitializes all the private member variables, am i going to run into memory issues calling myObj._Reset() and reinstantiating by recreating the shared ptr using the create() method again?



It depends on what _Reset() does… it’s not a standard method in C++ so I have no idea where it comes from.

For general information on the difference between using shared_ptr's reset() and assignment, see this post.

Edit: just realised that _Reset() is part of the shared_ptr's implementation. As you can tell from the underscore in the name, you’re not supposed to call that yourself and it should not be accessible in the first place.


Thanks @paul.houx, that’s weird as it doesnt stop me from doing so and seems to achieve what i was trying to do… is there a different approach that would be safer / just as effective?