On 01/30/2012 09:32 AM, Michael Wild wrote:
Hi all
I can't seem to figure out how to wrap this in Boost.Python without the
need for auxiliary functions:
<snip>
string& s() { return m_s; }
The second argument to add_property should be an actual setter, not a
non-const-reference getter. In this case, you can write another free
function that delegates to the non-const-getter, then wrap that:
void set_s(A & a, std::string const & s) { a.s() = s; }
...
.add_property("s",
make_function(
(string const&(A::*)()const)&A::s,
return_value_policy<copy_const_reference>()),
make_function(&set_set)
)
HTH
Jim Bosch
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig