[C++-sig] Re: How to wrap reference-returning method as a property?
David Abrahams
dave at boost-consulting.com
Tue Jul 6 21:05:28 CEST 2004
"Mike Rovner" <mike at nospam.com> writes:
> Wirawan Purwanto wrote:
>
>> .add_property("hand", &Master::hand); // wouldn't work
>>
>> That interface wouldn't work since the reference's lifetime wasn't
>> known/specified. Is there anyway to fix this problem? I did not see
>
>>From BPL FAQ (http://tinyurl.com/24mnc):
>
> .add_property("hand",
> make_function(&Master::hand,
> return_value_policy<manage_new_object>()) )
Nooo!
Use return_internal_reference!
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list