AMDG On 06/04/2013 10:07 AM, Matus Chochlik wrote:
Hi,
I'm stuck at trying to make python bindings for a set of classes that use a non-c++-standard iteration protocol. I've made a minimal example of what I'm trying to do:
the python-ized classes look in essence like this:
//------------------------------------------------------------- class int_range;
<snip>
class _py_int_range;
class_<_py_int_range>("_py_int_range", init
()) .def("__iter__", &_py_int_range::iter) ; //------------------------------------------------------------- the problem is that when I register range_maker as follows...
//------------------------------------------------------------- class_
("range_maker") .def("make", &range_maker::make) ; //------------------------------------------------------------- ... it compiles but (obviously) fails in python at run-time because range_maker::make returns int_range and not _py_int_range.
<snip>
It would probably work better if you adapted int_range directly instead of creating a separate class for python. (Def can take a function pointer. You don't have to use a member function) In Christ, Steven Watanabe