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
73db250c
Commit
73db250c
authored
Oct 06, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for vector[bool].at(...)
parent
338d5c44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+13
-0
tests/run/cpp_stl_vector.pyx
tests/run/cpp_stl_vector.pyx
+2
-1
No files found.
Cython/Compiler/PyrexTypes.py
View file @
73db250c
...
...
@@ -3478,6 +3478,19 @@ class CppClassType(CType):
if
self
.
namespace
is
not
None
:
specialized
.
namespace
=
self
.
namespace
.
specialize
(
values
)
specialized
.
scope
=
self
.
scope
.
specialize
(
values
,
specialized
)
if
self
.
cname
==
'std::vector'
:
# vector<bool> is special cased in the C++ standard, and its
# accessors do not necessarily return references to the underlying
# elements (which may be bit-packed).
# http://www.cplusplus.com/reference/vector/vector-bool/
# Here we pretend that the various methods return bool values
# (as the actual returned values are coercable to such, and
# we don't support call expressions as lvalues).
T
=
values
[
self
.
templates
[
0
]]
if
T
.
empty_declaration_code
()
==
'bool'
:
for
bit_ref_returner
in
(
'at'
,
'back'
,
'front'
):
if
bit_ref_returner
in
specialized
.
scope
.
entries
:
specialized
.
scope
.
entries
[
bit_ref_returner
].
type
.
return_type
=
T
return
specialized
def
deduce_template_params
(
self
,
actual
):
...
...
tests/run/cpp_stl_vector.pyx
View file @
73db250c
...
...
@@ -172,7 +172,8 @@ def test_bool_vector_get_set():
# Test access.
assert
not
v
[
0
],
v
assert
v
[
1
],
v
# assert v.at(0)
assert
not
v
.
at
(
0
),
v
assert
v
.
at
(
1
),
v
v
[
0
]
=
True
v
[
1
]
=
False
assert
<
object
>
v
==
[
True
,
False
,
True
,
True
,
True
]
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