[C++-sig] how to wrap getter returning shared_ptr<T>
David Abrahams
dave at boost-consulting.com
Tue Dec 10 04:52:30 CET 2002
"Langston, Matthew David" <langston at SLAC.Stanford.EDU> writes:
> I answered my own question through trial-and-error experimentation. If
> I want to have Boost.Python return a "shared_ptr < Bar >", then I must
> export Bar to python using the second template argument to class_ as
> follows:
>
> class_< Bar, shared_ptr < Bar > > ( "Bar" ).add_property ("message",
> &Bar::get_Message);
>
> Matt
<snip>
> I naively expected Boost.Python to just "do the right thing" w.r.t. a
> member function returning a boost::shared_ptr. What am I doing wrong?
>
> Warmest regards, Matt
Matt,
Please see http://aspn.activestate.com/ASPN/Mail/Message/1456023
(especially the non-quoted section at the bottom).
I've been waiting for more feedback about the issues discussed
there. So far I'm leaning fairly strongly away from the "just do the
right thing" approach and toward the register_shared_ptr<T>()
approach on the "don't pay for what you don't use" theory.
-Dave
--
David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
More information about the Cplusplus-sig
mailing list