Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
Modules
cython
Commits
b1a3373109d6
Commit
b1a3373109d6
authored
4 years ago
by
will
Browse files
Options
Downloads
Patches
Plain Diff
Add missing unordered_map template defaults (GH-3686)
parent
b2c32be61bd5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cython/Includes/libcpp/unordered_map.pxd
+1
-1
1 addition, 1 deletion
Cython/Includes/libcpp/unordered_map.pxd
tests/run/cpp_stl_cpp11.pyx
+15
-0
15 additions, 0 deletions
tests/run/cpp_stl_cpp11.pyx
tests/run/cpp_unordered_map_helper.h
+13
-0
13 additions, 0 deletions
tests/run/cpp_unordered_map_helper.h
with
29 additions
and
1 deletion
Cython/Includes/libcpp/unordered_map.pxd
+
1
−
1
View file @
b1a33731
from
.utility
cimport
pair
cdef
extern
from
"
<unordered_map>
"
namespace
"
std
"
nogil
:
cdef
cppclass
unordered_map
[
T
,
U
]:
cdef
cppclass
unordered_map
[
T
,
U
,
HASH
=*
,
PRED
=*
,
ALLOCATOR
=*
]:
ctypedef
T
key_type
ctypedef
U
mapped_type
ctypedef
pair
[
const
T
,
U
]
value_type
...
...
This diff is collapsed.
Click to expand it.
tests/run/cpp_stl_cpp11.pyx
+
15
−
0
View file @
b1a33731
...
...
@@ -140,6 +140,11 @@
return
"
pass
"
cdef
extern
from
"
cpp_unordered_map_helper.h
"
:
cdef
cppclass
IntVectorHash
:
pass
def
test_unordered_map_functionality
():
"""
>>>
test_unordered_map_functionality
()
...
...
@@ -153,6 +158,8 @@
unordered_map
[
int
,
int
]
int_map2
unordered_map
[
int
,
int
*
]
intptr_map
const
int
*
intptr
unordered_map
[
vector
[
int
],
int
,
IntVectorHash
]
int_vector_map
vector
[
int
]
intvec
assert
int_map
[
1
]
==
2
assert
int_map
.
size
()
==
1
assert
int_map
.
erase
(
1
)
==
1
# returns number of elements erased
...
...
@@ -183,4 +190,12 @@
intptr_map
[
0
]
=
NULL
intptr
=
intptr_map
.
const_at
(
0
)
intvec
=
[
1
,
2
]
int_vector_map
[
intvec
]
=
3
intvec
=
[
4
,
5
]
int_vector_map
[
intvec
]
=
6
assert
int_vector_map
[
intvec
]
==
6
intvec
=
[
1
,
2
]
assert
int_vector_map
[
intvec
]
==
3
return
"
pass
"
This diff is collapsed.
Click to expand it.
tests/run/cpp_unordered_map_helper.h
0 → 100644
+
13
−
0
View file @
b1a33731
#include
<functional>
#include
<vector>
struct
IntVectorHash
{
size_t
operator
()(
const
std
::
vector
<
int
>&
v
)
const
{
std
::
hash
<
int
>
hasher
;
size_t
seed
=
0
;
for
(
int
i
:
v
)
{
seed
^=
hasher
(
i
)
+
0x9e3779b9
+
(
seed
<<
6
)
+
(
seed
>>
2
);
}
return
seed
;
}
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment