Hello,
I was wanting to use C++s' back_inserter in Cython, and I got it working.
I'm writing the list to ask about what more I should do before submitting a
pull request.
In short, the following definitions were sufficient:
##Define the basic iterator types (this is incomplete)
cdef extern from "<iterator>" namespace "std":
cdef cppclass iterator[Category,T,Distance,Pointer,Reference]:
pass
cdef cppclass output_iterator_tag:
pass
#The goal here is to get back_inserter working, as it is handy.
cdef cppclass
back_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
pass
back_insert_iterator[CONTAINER] back_inserter[CONTAINER](CONTAINER &)
##Not shown here, but I've gotten C++11's move algorithm to work, too,
##using same kind of prototype
cdef extern from "<algorithm>" namespace "std":
OUTPUT copy[INPUT,OUTPUT](INPUT,INPUT,OUTPUT)
I've worked up a tiny test package that is on GitHub:
https://github.com/molpopgen/cython_cpp_iterators
The tests work, and I can indeed copy amongst C++ containers.
I've also gotten the C++ move algorithm to work. The prototype is the same
as for 'copy' above.
I'd be willing to define the remaining classes from <iterator> and add a
.pxd file.
Any input would be appreciated.
Thanks,
Kevin
_______________________________________________
cython-devel mailing list
[email protected]
https://mail.python.org/mailman/listinfo/cython-devel