[C++-sig] Enhanced shared_ptr support

David Abrahams dave at boost-consulting.com
Thu Feb 27 04:49:03 CET 2003


A few days ago I checked in some changes to the way shared_ptrs get
converted to Python.  A while back I had added a special shared_ptr
deleter which caused all shared_ptr conversions from python to
maintain the lifetime of the owning Python object, not of the C++
object.  In other words, we'll have this:

      shared_ptr<T>         T
     +------+------+     +------+
     |      |      |     |      |
     |  *   |   *------->|      |
     |  ||  |      |     |      |
     +--||--+------+     +------+
        ||                  /\
        \/                  ||
     +-----------------+    ||
     |                 |    ||
     | Python Object *======++
     |                 |
     +-----------------+

The double lines represent ownership relationships.  Now, when such a
shared_ptr is converted back to python, the owned Python object is
returned, rather than a new Python object being built around the
shared_ptr, sharing ownership of the T object with the Python object
above.

-Dave

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list