From b370ed0bf93ecf0ff51d29e7fc132c433b2aa1be Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 9 Jun 2022 12:07:15 +0100 Subject: libstdc++: Make std::hash> allocator-agnostic (LWG 3705) This new library issue was recently moved to Tentatively Ready by an LWG poll, so I'm making the change on trunk. As noted in PR libstc++/105907 the std::hash specializations for PMR strings were not treated as slow hashes by the unordered containers, so this change preserves that. The new specializations for custom allocators are also not treated as slow, for the same reason. For the versioned namespace (i.e. unstable ABI) we don't have to worry about that, so can enable hash code caching for all basic_string specializations. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (__hash_str_base): New class template. (hash, A>>): Define partial specialization for each of the standard character types. (hash, hash, hash, hash) (hash): Remove explicit specializations. * include/std/string (__hash_string_base): Remove class template. (hash, hash, hash) (hash, hash): Remove explicit specializations. * testsuite/21_strings/basic_string/hash/hash.cc: Test with custom allocators. * testsuite/21_strings/basic_string/hash/hash_char8_t.cc: Likewise. --- libstdc++-v3/include/std/string | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'libstdc++-v3/include/std') diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string index 4a06330..37a4aab 100644 --- a/libstdc++-v3/include/std/string +++ b/libstdc++-v3/include/std/string @@ -69,39 +69,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using u32string = basic_string; using wstring = basic_string; } // namespace pmr - - template - struct __hash_string_base - : public __hash_base - { - size_t - operator()(const _Str& __s) const noexcept - { return hash>{}(__s); } - }; - - template<> - struct hash - : public __hash_string_base - { }; -#ifdef _GLIBCXX_USE_CHAR8_T - template<> - struct hash - : public __hash_string_base - { }; -#endif - template<> - struct hash - : public __hash_string_base - { }; - template<> - struct hash - : public __hash_string_base - { }; - template<> - struct hash - : public __hash_string_base - { }; - _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++17 -- cgit v1.1