[C++-sig] Help wrapping an unconventional setter

Craig Bosma craig.bosma at gmail.com
Thu Oct 23 18:14:34 CEST 2008


Hi,
I'm pretty new to Boost.Python, and am trying to wrap a simple class similar
to:

class Foo {
public:
    float value() const { return value_; }
    float& value() { return value_; }
private:
    float value_;
};

I have no problem wrapping value() as a read-only property, like so:

class_<Foo>("Foo")
  .add_property("value", (float (Foo::*)(void) const)&Foo::value)
  ;

But I'm having a difficult time determining how to wrap the unconventional
'setter' method for read-write property access; as you can see it returns a
non-const reference to be set rather than taking the new value as an
argument. Any suggestions?

Thanks,

Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081023/6a03b189/attachment.htm>


More information about the Cplusplus-sig mailing list