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
bc3dd1a2
Commit
bc3dd1a2
authored
May 07, 2021
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add C++ "to_string()" function to declarations.
parent
21aeab70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
Cython/Includes/libcpp/string.pxd
Cython/Includes/libcpp/string.pxd
+11
-0
tests/run/cpp_stl_string.pyx
tests/run/cpp_stl_string.pyx
+13
-1
No files found.
Cython/Includes/libcpp/string.pxd
View file @
bc3dd1a2
...
...
@@ -173,3 +173,14 @@ cdef extern from "<string>" namespace "std" nogil:
bint
operator
>=
(
const
string
&
)
bint
operator
>=
(
const
char
*
)
string
to_string
(
int
val
)
string
to_string
(
long
val
)
string
to_string
(
long
long
val
)
string
to_string
(
unsigned
val
)
string
to_string
(
unsigned
long
val
)
string
to_string
(
unsigned
long
long
val
)
string
to_string
(
float
val
)
string
to_string
(
double
val
)
string
to_string
(
long
double
val
)
tests/run/cpp_stl_string.pyx
View file @
bc3dd1a2
...
...
@@ -3,7 +3,7 @@
cimport
cython
from
libcpp.string
cimport
string
from
libcpp.string
cimport
string
,
to_string
b_asdf
=
b'asdf'
b_asdg
=
b'asdg'
...
...
@@ -346,6 +346,18 @@ def test_iteration(string s):
return
[
c
for
c
in
s
]
def
test_to_string
(
x
):
"""
>>> print(test_to_string(5))
si=5 sl=5
>>> print(test_to_string(-5))
si=-5 sl=-5
"""
si
=
to_string
(
<
int
>
x
).
decode
(
'ascii'
)
sl
=
to_string
(
<
long
>
x
).
decode
(
'ascii'
)
return
f"si=
{
si
}
sl=
{
sl
}
"
_WARNINGS
=
"""
21:31: Cannot pass Python object as C++ data structure reference (string &), will pass by copy.
"""
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