Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
b7ca7dc3
Commit
b7ca7dc3
authored
Jul 06, 2018
by
scoder
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2447 from gabrieldemarmiesse/test_wrapping_cplusplus_6
Added tests for "Using C++ in Cython" part 6
parents
ed6a7e2e
0183926e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
+12
-0
docs/src/userguide/wrapping_CPlusPlus.rst
docs/src/userguide/wrapping_CPlusPlus.rst
+2
-5
No files found.
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
0 → 100644
View file @
b7ca7dc3
# distutils: language = c++
from
libcpp.vector
cimport
vector
def
main
():
cdef
vector
[
int
]
v
=
[
4
,
6
,
5
,
10
,
3
]
cdef
int
value
for
value
in
v
:
print
(
value
)
return
[
x
*
x
for
x
in
v
if
x
%
2
==
0
]
docs/src/userguide/wrapping_CPlusPlus.rst
View file @
b7ca7dc3
...
...
@@ -351,12 +351,9 @@ inside of containers, e.g. a C++ vector of maps of strings.
Iteration over stl containers (or indeed any class with ``begin()`` and
``end()`` methods returning an object supporting incrementing, dereferencing,
and comparison) is supported via the ``for .. in`` syntax (including in list
comprehensions). For example, one can write:
:
comprehensions). For example, one can write:
cdef vector[int] v = ...
for value in v:
f(value)
return [x*x for x in v if x % 2 == 0]
.. literalinclude:: ../../examples/userguide/wrapping_CPlusPlus/iterate.pyx
If the loop target variable is unspecified, an assignment from type
``*container.begin()`` is used for :ref:`type inference <compiler-directives>`.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment