Commit f72b9bd0 authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Fixed a bug in the cpp example and moved it to the examples directory.

parent 04780910
# distutils: language = c++
from libcpp.string cimport string
def get_bytes():
py_bytes_object = b'hello world'
cdef string s = py_bytes_object
s.append('abc')
py_bytes_object = s
return py_bytes_object
......@@ -365,18 +365,9 @@ C++ strings
When wrapping a C++ library, strings will usually come in the form of
the :c:type:`std::string` class. As with C strings, Python byte strings
automatically coerce from and to C++ strings::
automatically coerce from and to C++ strings:
# distutils: language = c++
from libcpp.string cimport string
cdef string s = py_bytes_object
try:
s.append('abc')
py_bytes_object = s
finally:
del s
.. literalinclude:: ../../examples/tutorial/string/cpp_string.pyx
The memory management situation is different than in C because the
creation of a C++ string makes an independent copy of the string
......
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