[C++-sig] Re: Shared Pointers and Boost.Python

Brian Hall bhall at gamers-fix.com
Sun Jul 25 17:32:04 CEST 2004


Actually, everything he did was fine.  Wrapping classes with
shared_ptr is almost completely pointless now, since any Python object
holding an X object can be converted to a shared_ptr<X>.  The
shared_ptr has a custom deleter that manages the owning Python object's
lifetime.

You might want to use register_ptr_to_python<shared_ptr<X> >() for
some shared pointers if you ever create them from C++ code, but in
this case it never happens so they can all be automatically converted
back into Python objects by (we just extract the owning Python object
from the deleter).

-----

Actually before I tried putting the shared_ptr<> declaration in the class_
exposure, the application would crash in some code having to do with the
custom deleter.  It also was saying something about being unable to make a
to_python coverter.

Brian





More information about the Cplusplus-sig mailing list