diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-01-22 00:35:45 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-01-23 22:47:00 +0000 |
commit | 084680db9af077ca37c5523a58b6c11e090e7335 (patch) | |
tree | 3fedd125c00da3ce92d56124b7f166f25e87ea0f /libstdc++-v3 | |
parent | 2d8a9ad4a922e3248d0f6c60a6331be6f47dc435 (diff) | |
download | gcc-084680db9af077ca37c5523a58b6c11e090e7335.zip gcc-084680db9af077ca37c5523a58b6c11e090e7335.tar.gz gcc-084680db9af077ca37c5523a58b6c11e090e7335.tar.bz2 |
libstdc++: Restore support for unordered_map<const T, ...> [PR104174]
I broke this unintentionally in r12-4259.
libstdc++-v3/ChangeLog:
PR libstdc++/104174
* include/bits/hashtable_policy.h (_Map_base): Add partial
specialization for maps with const key types.
* testsuite/23_containers/unordered_map/104174.cc: New test.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/include/bits/hashtable_policy.h | 11 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/unordered_map/104174.cc | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 3b60eb9..0f0b0f9 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -812,6 +812,17 @@ namespace __detail return __pos->second; } + // Partial specialization for unordered_map<const T, U>, see PR 104174. + template<typename _Key, typename _Val, typename _Alloc, typename _Equal, + typename _Hash, typename _RangeHash, typename _Unused, + typename _RehashPolicy, typename _Traits, bool __uniq> + struct _Map_base<const _Key, pair<const _Key, _Val>, + _Alloc, _Select1st, _Equal, _Hash, + _RangeHash, _Unused, _RehashPolicy, _Traits, __uniq> + : _Map_base<_Key, pair<const _Key, _Val>, _Alloc, _Select1st, _Equal, _Hash, + _RangeHash, _Unused, _RehashPolicy, _Traits, __uniq> + { }; + /** * Primary class template _Insert_base. * diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/104174.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/104174.cc new file mode 100644 index 0000000..4007425 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/104174.cc @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } +// PR libstdc++/104174 unordered_map<const T, U, H> fails +#include <unordered_map> +std::unordered_map<const int, int, std::hash<int>> m; |