Commit 57385bf9 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2441 from gabrieldemarmiesse/test_wrapping_cplusplus_1

Added tests for "Using C++ in Cython" part 1
parents 3623e6c7 af8b69ea
# distutils: language = c++
cdef extern from "<vector>" namespace "std":
cdef cppclass vector[T]:
cppclass iterator:
T operator*()
iterator operator++()
bint operator==(iterator)
bint operator!=(iterator)
vector()
void push_back(T&)
T& operator[](int)
T& at(int)
iterator begin()
iterator end()
cdef vector[int].iterator iter #iter is declared as being of type vector<int>::iterator
......@@ -252,23 +252,9 @@ themselves::
Nested class declarations
--------------------------
C++ allows nested class declaration. Class declarations can also be
nested in Cython::
cdef extern from "<vector>" namespace "std":
cdef cppclass vector[T]:
cppclass iterator:
T operator*()
iterator operator++()
bint operator==(iterator)
bint operator!=(iterator)
vector()
void push_back(T&)
T& operator[](int)
T& at(int)
iterator begin()
iterator end()
cdef vector[int].iterator iter #iter is declared as being of type vector<int>::iterator
nested in Cython:
.. literalinclude:: ../../examples/userguide/wrapping_CPlusPlus/nested_class.pyx
Note that the nested class is declared with a ``cppclass`` but without a ``cdef``.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment