This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.
Section: 20.4.5 [string.view.hash] Status: Resolved Submitter: Nicolai Josuttis Opened: 2016-11-09 Last modified: 2016-12-23
Priority: Not Prioritized
View all issues with Resolved status.
Under certain conditions we want to be able to use string_view instead of string. As a consequence both types should behave the same as long we talk about value specific behavior (if possible). For this reason, we should require that both strings and string_view yield the same hash values.Should be solved in C++17 to ensure that following this use does not require to change hash values (which is allowed but possibly unfortunate).
Resolved by P0513R0
This wording is relative to N4606.
A more formal formulation would be:
For any sv of type SV (being string_view, u16string_view, u32string_view, or wstring_view) and s of the corresponding type S (being string, u16string, u32string, or wstring), hash<SV>()(sv) == hash<S>()(s).
Edit 20.4.5 [string.view.hash] as indicated:
template<> struct hash<string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>>;
-1- The template specializations shall meet the requirements of class template hash (19.14.16 [unord.hash]).