Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2002-11-19 17:36:00


David Abrahams <dave_at_[hidden]> writes:

> "Daniel Paull" <dlp_at_[hidden]> writes:
>
> Please post Boost.Python questions to the C++-sig:
>
> http://www.python.org/sigs/c++-sig/
>
>> Hi all,
>>
>> I'm having trouble with some object lifetime issues using Boost Python
>> V2. Basically, I'm in a situation where both C++ and Python want to
>> delete the same object.
>
>> Below is a simple example of the scenario. Consider the two classes A
>> and B. An instance of A is passed to B via the setA() method. B then
>> assumes ownership of A and deletes it in it's destructor. NOTE: the
>> behaviour of the C++ code can not be changed currently.
>>
>
> There's currently no good way to express what you want in
> Boost.Python.

Daniel,

Since I checked in the changes to support passing auto_ptr<> objects
into and out of wrapped functions, you should be able to do what you
need. You'll need to write a thin wrapper for your function which
takes an auto_ptr<A> argument and calls its release() member function
to get the object which will be adopted by the C++ code.

HTH,
Dave

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net