[committed] libstdc++: Restore support for unordered_map<const T, ...> [PR104174]
Commit Message
Tested powerpc64le-linux, pushed to trunk.
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.
---
libstdc++-v3/include/bits/hashtable_policy.h | 11 +++++++++++
.../testsuite/23_containers/unordered_map/104174.cc | 4 ++++
2 files changed, 15 insertions(+)
create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_map/104174.cc
@@ -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.
*
new file mode 100644
@@ -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;