[C++-sig] Raw pointer wrapper

Roman Yakovenko roman.yakovenko at gmail.com
Thu Jan 25 21:00:39 CET 2007


On 1/25/07, Paul Guse <paul at mustagh.com> wrote:
>
>
> Hello.
> I have a reference counted c++ class that I expose to python using boost. I
> would like to keep the reference counting managed on the c++ side of things
> and just wrap the raw pointer in a boost::python::object.
> Since I increment the reference count upon retrieval, I would like to
> decrement the count when the python object is destroyed.
> Is there a way to use boost to wrap this c++ class so that it acts like a
> boost python object, but has it's reference count decremented when the
> object goes out of scope?
>
> In other words I need a class that can act like a python object, store a raw
> pointer, and decrement on destruction.
> Any thoughts would be greatly appreciated. Thanks!
> Paul

http://www.boost.org/libs/smart_ptr/intrusive_ptr.html
I could be wrong, but it seems t me that intrusive_ptr is the way to go.
Search this mailing list and you will relevant information and I think
code that
exposes it.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list