
David Abrahams
"Daniel Paull"
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@boost-consulting.com * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution