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
0d01f077
Commit
0d01f077
authored
Jul 07, 2018
by
scoder
Committed by
GitHub
Jul 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2220 from Alexhuszagh/forward_list
Added support for C++11's <forward_list>.
parents
3824ba4d
e07c4efc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
0 deletions
+141
-0
Cython/Includes/libcpp/forward_list.pxd
Cython/Includes/libcpp/forward_list.pxd
+62
-0
tests/run/cpp_stl_forward_list.pyx
tests/run/cpp_stl_forward_list.pyx
+79
-0
No files found.
Cython/Includes/libcpp/forward_list.pxd
0 → 100644
View file @
0d01f077
cdef
extern
from
"<forward_list>"
namespace
"std"
nogil
:
cdef
cppclass
forward_list
[
T
,
ALLOCATOR
=*
]:
ctypedef
T
value_type
ctypedef
ALLOCATOR
allocator_type
# these should really be allocator_type.size_type and
# allocator_type.difference_type to be true to the C++ definition
# but cython doesn't support deferred access on template arguments
ctypedef
size_t
size_type
ctypedef
ptrdiff_t
difference_type
cppclass
iterator
:
iterator
()
iterator
(
iterator
&
)
T
&
operator
*
()
iterator
operator
++
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
const_iterator
(
iterator
):
pass
forward_list
()
except
+
forward_list
(
forward_list
&
)
except
+
forward_list
(
size_t
,
T
&
)
except
+
#forward_list& operator=(forward_list&)
bint
operator
==
(
forward_list
&
,
forward_list
&
)
bint
operator
!=
(
forward_list
&
,
forward_list
&
)
bint
operator
<
(
forward_list
&
,
forward_list
&
)
bint
operator
>
(
forward_list
&
,
forward_list
&
)
bint
operator
<=
(
forward_list
&
,
forward_list
&
)
bint
operator
>=
(
forward_list
&
,
forward_list
&
)
void
assign
(
size_t
,
T
&
)
T
&
front
()
iterator
before_begin
()
const_iterator
const_before_begin
"before_begin"
()
iterator
begin
()
const_iterator
const_begin
"begin"
()
iterator
end
()
const_iterator
const_end
"end"
()
bint
empty
()
size_t
max_size
()
void
clear
()
iterator
insert_after
(
iterator
,
T
&
)
void
insert_after
(
iterator
,
size_t
,
T
&
)
iterator
erase_after
(
iterator
)
iterator
erase_after
(
iterator
,
iterator
)
void
push_front
(
T
&
)
void
pop_front
()
void
resize
(
size_t
)
void
resize
(
size_t
,
T
&
)
void
swap
(
forward_list
&
)
void
merge
(
forward_list
&
)
void
merge
[
Compare
](
forward_list
&
,
Compare
)
void
splice_after
(
iterator
,
forward_list
&
)
void
splice_after
(
iterator
,
forward_list
&
,
iterator
)
void
splice_after
(
iterator
,
forward_list
&
,
iterator
,
iterator
)
void
remove
(
const
T
&
)
void
remove_if
[
Predicate
](
Predicate
)
void
reverse
()
void
unique
()
void
unique
[
Predicate
](
Predicate
)
void
sort
()
void
sort
[
Compare
](
Compare
)
tests/run/cpp_stl_forward_list.pyx
0 → 100644
View file @
0d01f077
# mode: run
# tag: cpp, werror, cpp11
from
cython.operator
cimport
dereference
as
deref
from
cython.operator
cimport
preincrement
as
incr
from
libcpp.forward_list
cimport
forward_list
from
libcpp
cimport
bool
as
cbool
def
simple_iteration_test
(
L
):
"""
>>> iteration_test([1,2,4,8])
8
4
2
1
>>> iteration_test([8,4,2,1])
1
2
4
8
"""
cdef
forward_list
[
int
]
l
for
a
in
L
:
l
.
push_front
(
a
)
for
a
in
l
:
print
(
a
)
def
iteration_test
(
L
):
"""
>>> iteration_test([1,2,4,8])
8
4
2
1
>>> iteration_test([8,4,2,1])
1
2
4
8
"""
l
=
new
forward_list
[
int
]()
try
:
for
a
in
L
:
l
.
push_front
(
a
)
it
=
l
.
begin
()
while
it
!=
l
.
end
():
a
=
deref
(
it
)
incr
(
it
)
print
(
a
)
finally
:
del
l
def
test_value_type
(
x
):
"""
>>> test_value_type(2)
2.0
>>> test_value_type(2.5)
2.5
"""
cdef
forward_list
[
double
].
value_type
val
=
x
return
val
def
test_value_type_complex
(
x
):
"""
>>> test_value_type_complex(2)
(2+0j)
"""
cdef
forward_list
[
double
complex
].
value_type
val
=
x
return
val
# Tests GitHub issue #1788.
cdef
cppclass
MyForwardList
[
T
](
forward_list
):
pass
cdef
cppclass
Ints
(
MyForwardList
[
int
]):
pass
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