[C++-sig] Return by value/pointer and properties
Trevor Blackwell
tlb at anybots.com
Fri May 28 20:01:22 CEST 2004
I wish I understood better how boost.python wraps return values of
accessors created with def_readwrite or add_property. In neither case is
there any place to specify a return_value_policy.
I see empirically that if I define:
struct bar_t {
int buz;
};
struct foo_t {
bar_t bar;
};
class_<bar_t>("bar_t")
.def_readwrite("buz", &bar_t::buz);
class_<foo_t>("foo_t")
.def_readwrite("bar", &foo_t::bar);
then calling foo.bar returns by pointer. (So, for instance,
foo.bar.buz=3; print foo.bar.buz; prints 3). But is it a
custodian_and_ward, or what? What if I wanted it to wrap by value? I can
do it by using add_property and a getter method that returns by value,
but that's kind of cumbersome.
--
Trevor Blackwell tlb at anybots.com (650) 210-9272
More information about the Cplusplus-sig
mailing list