[C++-sig] Custom smart pointer with same behaviour as shared_ptr

Andrea mariofutire at googlemail.com
Fri Jan 18 23:13:10 CET 2008


john haddon wrote:
> 
> we had similar problems when wrapping a library where we used 
> boost::intrusive_ptr as our
> smart pointer of choice. we managed to work around most of the problems 
> using the magic
> incantations in this file :
> 
> http://cortex-vfx.googlecode.com/svn/trunk/include/IECore/bindings/IntrusivePtrPatch.h
> 
> you can see an example of how we use that in this file :
> 
> http://cortex-vfx.googlecode.com/svn/trunk/src/IECore/bindings/ObjectBinding.cpp
> 
> hopefully those might give you some clue as to how to fix your problems 
> too...
> 
> cheers...
> john

Thanks for the suggestion.
I end up debugging until I found a place where the *magic* boost::shared_ptr was created (out of the 
blue) and I ended up in the file

<boost/python/converter/shared_ptr_from_python.hpp>

It is the same file you sent me, and I've seen what you did to change it.
So I am going to try it out.

Could you please tell me what you meant by

 > "we managed to work around most of the problems"

since it looks like I will be following the same steps as you.

Maybe this whole approach should be documented (if it is not too dodgy)

Andrea




More information about the Cplusplus-sig mailing list