|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-11-16 08:18:28
Hi,
In Boost.Python, I am going to start using custom deleters to enable
me to produce shared_ptr<T> from any Python object which contains a T,
while keeping the Python object alive. I can't believe I didn't think
of this earlier, and I want to thank Peter Dimov for putting me onto
the idea.
Each such shared_ptr<T> contains a pointer to the owning Python
object, whose identity is associated with that of the T object it
contains. When these shared_ptrs are converted back to Python, I
currently have to build a new Python object around a copy of the
shared_ptr<T>, so that now there are two Python objects using the same
C++ object's "guts". It would be very useful if I could introspect
about the deleter, and find out that it was using my custom deleter,
extract the Python object pointer, and simply return that instead of
building a new Python object.
Looking at the code, I can see a few ways to hack that functionality
in, but I wonder if we should think about making it part of the public
interface? After all, the deleter is part of the public interface for
shared_ptr creation...
-Dave
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk