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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b62ded56
Commit
b62ded56
authored
Aug 23, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Note on references and C++ container iteration.
parent
2be549d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
docs/src/userguide/wrapping_CPlusPlus.rst
docs/src/userguide/wrapping_CPlusPlus.rst
+20
-5
No files found.
docs/src/userguide/wrapping_CPlusPlus.rst
View file @
b62ded56
...
...
@@ -500,6 +500,16 @@ The items in the containers are converted to a corresponding type
automatically, which includes recursively converting containers
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::
cdef vector[int] v = ...
for value in v:
f(value)
return [x in v if x % 2 == 0]
Simplified wrapping with default constructor
--------------------------------------------
...
...
@@ -606,6 +616,16 @@ you can declare it using the Python @staticmethod decorator, i.e.::
void do_something()
Declaring/Using References
---------------------------
Cython supports declaring lvalue references using the standard ``Type&`` syntax.
Note, however, that it is unnecessary to declare the arguments of extern
functions as references (const or otherwise) as it has no impact on the
caller's syntax.
Caveats and Limitations
========================
...
...
@@ -623,11 +643,6 @@ module which:
* contains minimal forwarding functions in C++, each of which calls the
respective pure-C function
Declaring/Using References
---------------------------
Question: How do you declare and call a function that takes a reference as an argument?
C++ left-values
----------------
...
...
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