[Cython] Exposing C++'s <iterator>
krthornt at uci.edu
Fri Oct 16 15:50:41 EDT 2015
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
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]:
cdef cppclass output_iterator_tag:
#The goal here is to get back_inserter working, as it is handy.
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":
I've worked up a tiny test package that is on GitHub:
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
Any input would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cython-devel