c++ - shared_ptr from pointer -


i have class can't created on heap , has private destructor.

but there function returns pointer such constructed object. want make shared pointer it:

myclass *getmyclasspointer() {...}  boost::shared_ptr<myclass> ptr; ptr = boost::shared_ptr<myclass>(getmyclasspointer()); // [x] 

error: ‘myclass::~myclass()’ private

any ways?

yes.

it sounds instance being dynamically allocated function has access private constructor (either member or friend). there should public function cleaning instance when you're done it, has access private destructor (even though don't).

use shared_ptr constructor accepts custom deleter, , wire cleanup function class provides (may need wrapper function signature match).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -