I have a function in an external library, which looks like this;
bool CreateTheThing(MyThing *& pOut);
I give the function a raw pointer, and it allocates memory and assigns the pointer. It's then my responsibility to free the memory, when I'm done.
Obviously, I'd like to put this result into a unique_ptr<MyThing>
.
I could create a temporary raw pointer for the API call, and pass it into the constructor for the unique_ptr
, but is there a more direct method through which the API could work directly with the internal pointer of the unique_ptr
?
Aucun commentaire:
Enregistrer un commentaire