[C++-sig] boost python class member getter/setter same name different only by constness

MM finjulhich at gmail.com
Thu Oct 2 22:09:20 CEST 2014


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?

MM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20141002/98327e99/attachment.html>


More information about the Cplusplus-sig mailing list