on Tue Feb 10 2009, Gennadiy Rozental <rogeeff-AT-gmail.com> wrote: > Hi, > > I need to implement some translation in a getter and setter for particular > field. > > I am getting compile time errors, I am not sure how to fix. I am using 1.33.1. > > Here is what I do: > > template<typename T> > struct Getter { > explicit Getter( MyClass T::* mem ) : m_member( mem ) {} > > bp::object operator()( T const& obj ) const > { > return /* conversion here */; > } > > MyClass T::* m_member; > }; > > template<typename T> > Getter<T> > make_getter( MyClass T::* mem ) > { > return Getter<T>( mem ); > } > > ....
Frankly I'm not sure it's possible to use a function object in that way. Have you tried simply using the data member pointer without the wrapper? bp::class_< MyClass >( "MyClass", bp::no_init ) .add_property( "field", &MyClass::field ) ?? > bp::class_< MyClass >( "MyClass", bp::no_init ) > .add_property( "field", make_getter( &MyClass::field ) ) -- Dave Abrahams BoostPro Computing http://www.boostpro.com _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig