[C++-sig] wrapping reference members
Sebastian Kraemer
basti.kr at gmail.com
Wed Jul 22 16:56:46 CEST 2009
> I would think that .def_readwrite would do what you need. If it doesn't
> look at using .def_property and get/set pair. Caveat: making sure that
> 'a' stays a valid reference is your problem. Python will happily crash
> horribly (if you are lucky) in response to bogus pointers or references.
Thanks for your fast answer! I tried it with following code:
class_<Foo>("Foo", init<>())
.def_readwrite("a", &Foo::a)
;
But it raises the error:
error: cannot create pointer to reference member 'Foo::a'
And it seems it's really not possible to create a pointer to a reference in c++ ;) So what else do I have to write instead of "&Foo::a"?
Cheers,
Sebastian
More information about the Cplusplus-sig
mailing list