I have some C API that handles object creation and destruction, it provides: createObject(...)
and destroy(...)
. I want to wrap it into some more modern construction/destruction mechanisms and use them with smart pointers. I am afraid that at some point I will forget to destroy the object, or some exception will occur.
I am aware of custom deleter function for shared_ptr
, but I can't explicitly call new
, because createOjbect
function handles initialization.
Can I use STL smart pointers in this situation? Do I have to, from scratch, implement a class with initialization in constructor, destruction in destructor and reference counting in this situation?
See Question&Answers more detail:os