I am used to build C++ programs and get it in Cython, but here I am trying to get the C++ 11 array
and it definitely doesn't work.
Here is my .pxd :
cdef extern from "<array>" namespace "std" nogil :
cdef cppclass array[T, size_t]:
ctypedef T value_type
cppclass iterator:
T& operator*()
iterator operator++()
iterator operator--()
iterator operator+(size_t)
iterator operator-(size_t)
bint operator==(iterator)
bint operator!=(iterator)
bint operator<(iterator)
bint operator>(iterator)
bint operator<=(iterator)
bint operator>=(iterator)
T& operator[](size_t)
array() except +
array(array&) except +
Most of this file is an adaptation from "vector.pxd", but I removed the allocator because c++11 array
doesn't need it. I used size_t
as second template argument but I am not sure about it.
The problem is, when I do :
from array11 cimport array
cdef array[int, 5] test
I get, when compiling :
unknown type in template argument
If I do :
from array11 cimport array
cdef array[int, 5] * test = new array[int, 5]()
I get :
new operator can only be applied to a C++ class
Any idea about what I am doing wrong?
Thanks!
See Question&Answers more detail:os