[C++-sig] Re: Custom by value type to python type conversion

David Abrahams dave at boost-consulting.com
Fri Nov 7 04:39:38 CET 2003


"Niall Douglas" <s_sourceforge at nedprod.com> writes:

> On 6 Nov 2003 at 16:15, Ralf W. Grosse-Kunstleve wrote:
>
>> > 	class_< FX::MappedData >("FXMappedData")
>> > 		.def_readwrite("name", &FX::MappedData::name);
>> 
>> Oh, this looks like a very well known problem. You have to use
>> .add_property instead. E.g. (untested):
>>         typedef return_value_policy<return_by_value> rbv;
>>         typedef default_call_policies dcp;
>> 
>>         .add_property("name", make_getter(&FX::MappedData::name,
>>         rbv()),
>>                               make_setter(&FX::MappedData::name,
>>                               dcp()))
>> 
>> Adjust the policies as necessary.
>
> If it's so well known, then why the hell isn't it in the FAQ so 
> everyone who uses BPL doesn't keep making the same mistake again & 
> again???

Because nobody has composed a reasonably informative FAQ entry that
will be intelligible to the general public.  Patches are always
welcome, if you can manage to write one which other people can
understand. 

> (I am grateful for the info - thanks - it just annoys me when this 
> happens, and it's not been the first time either).

Get over it; this is free software.  We do the best we can with the
resources we have and the contributions of others.


-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list