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
Kirill Smelkov
cython
Commits
04260b51
Commit
04260b51
authored
Jun 29, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved a code snippet to the examples directory.
parent
084a25f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
+15
-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 @
04260b51
# distutils: language = c++
from
libcpp.vector
cimport
vector
def
main
():
cdef
vector
[
int
]
v
cdef
int
i
,
value
for
i
in
range
(
10
):
v
.
push_back
(
i
)
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 @
04260b51
...
...
@@ -413,12 +413,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