
Hi, I am following a tutorial to expose a custom iterator to python, The iterator was used in C++ by for(T_ITERATOR it();it.Valid();it.Next()){ T_VALUE v=it.Value(); } And I wrote the following wrapper: template<class Klass, class KlassIter> struct iterator_wrappers { static Klass next(KlassIter& o) { o.Next(); Klass result = o.Value(); if (!o.Valid()) { PyErr_SetString(PyExc_StopIteration, "No more data."); boost::python::throw_error_already_set(); } return result; } static void wrap(const char* python_name) { //using namespace boost::python; class_<KlassIter>(python_name, init<>())//no_init .def("next", next) .def("__iter__", pass_through) ; } }; and expose it by iterator_wrappers<T_VALUE,T_ITERATOR>().wrap("t_iterator"); It compiles but when I am importing the module in python, there is an error saying: python: ../../../../libs/python/src/converter/registry.cpp:212: void boost::python::converter::registry::insert(PyObject* (*)(const void*), boost::python::type_info, const PyTypeObject* (*)()): Assertion `slot->m_to_python == 0' failed. Aborted Could some one please help me? Thanks a lot! Yong