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

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Nov 7 01:15:30 CET 2003


--- Niall Douglas <s_sourceforge at nedprod.com> 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.

Ralf


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree




More information about the Cplusplus-sig mailing list