Commit 4a4f6583 authored by Robert Bradshaw's avatar Robert Bradshaw

C++ iterator tests.

parent 2d177dda
......@@ -2184,6 +2184,8 @@ class NextNode(AtomicExprNode):
self.type = iterator_type.base_type
elif iterator_type.is_cpp_class:
self.type = iterator_type.scope.lookup("operator*").type.base_type.return_type
if self.type.is_reference:
self.type = self.type.ref_base_type
else:
self.type = py_object_type
self.is_temp = 1
......
# tag: cpp
from libcpp.vector cimport vector
def test_vector(py_v):
"""
>>> test_vector([1, 2, 3])
[1, 2, 3]
"""
cdef vector[int] v = py_v
cdef vector[int] result
with nogil:
for item in v:
result.push_back(item)
return result
def test_ptrs():
"""
>>> test_ptrs()
[1.0, 2.0, 3.0]
"""
cdef double a = 1
cdef double b = 2
cdef double c = 3
cdef vector[double*] v
v.push_back(&a)
v.push_back(&b)
v.push_back(&c)
cdef double* item
return [item[0] for item in v]
\ No newline at end of file
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