Scenario:
I use a method from the old C ++ library that returns a raw pointer to SomeClass , where SomeClass is an exported class from the library header, for example SomeClass.h
The following is the LibraryMethod signature I am using:
SomeClass* LibraryMethod();
I do not have access to modify the library. I use only binary and public header, which is a typical scenario.
I do not want to use raw pointers in my piece of code. Therefore, I have a generic pointer to SomeClass in my part of the code using the library API.
std::shared_ptr<SomeClass> some_class;
which I initialize to avoid storing a raw pointer to SomeClass
some_class = (std::shared_ptr<SomeClass>)LibraryMethod();
It basically works, but I want to understand the details here.
Question:
Is the above correct technique?
Am I leaking here?
Are there more efficient methods for handling such a scenario?
source share