[C++-sig] accessing nontrivial types

Anders Wallin anders.e.e.wallin at gmail.com
Fri Feb 5 16:01:40 CET 2010


> 3)
> bp::list getter (const MyClass& self)
> {
>        bp::list L
>        //move the values in self.ilist to L
>        return L
> }
> void setter (const MyClass& self, bp::list L)
> {
>        //move the values in L to self.ilist
> }
>
> class_<Myclass>("Myclass")
>        .def_readwrite("i", &Myclass::i)
>        .def_readwrite("f", &Myclass::f)
>        .add_property ("ilist", &getter, &setter)
> ;
>
> That's the gist of it. I am not sure if 1 works and 2 will be difficult, so I recommend 3

Thanks, this works. Incidentally, "getter" seems to be a defined
function somewhere else, so I had better luck naming it "listgetter"
or something similar.

AW


More information about the Cplusplus-sig mailing list