On 2014-10-02 16:09, MM wrote: > Hi > > class C { > public: > const std::string& name() const; > std::string& name(); > private: > std::string name_; > }; > > given this class C, how would I expose it to python with the class > property name? > > class_<C>("C"). > .add_property("name", &C::name, &C::name); > > or do I use 2 mem function pointers to distinguish the 2 names, and > pass those 2 pointers?
You need to disambiguate the two overloads. The cleanest way to do that is to introduce two (local) variables of the appropriate pointer-to-member-function types, then pass those variables to the 'add_property' call. In addition, I believe boost.python expects a different signature for the setter (a function taking a value-type argument), so you may have to provide a wrapper function for that, unless you want to modify the 'C' class in-place. HTH, Stefan -- ...ich hab' noch einen Koffer in Berlin... _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig