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.
string_view
objects and strings should yield the same hash valuesSection: 27.3.6 [string.view.hash] Status: Resolved Submitter: Nicolai Josuttis Opened: 2016-11-09 Last modified: 2016-11-21
Priority: Not Prioritized
View all issues with Resolved status.
Discussion:
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.
[2016-11-12, Issaquah]
Resolved by P0513R0
Proposed resolution:
This wording is relative to N4606.
A more formal formulation would be:
For any
sv
of typeSV
(beingstring_view
,u16string_view
,u32string_view
, orwstring_view
) ands
of the corresponding typeS
(beingstring
,u16string
,u32string
, orwstring
),hash<SV>()(sv) == hash<S>()(s)
.
Edit 27.3.6 [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
(22.10.19 [unord.hash]). The hash values shall be the same as the hash values for the corresponding string class (27.4.6 [basic.string.hash]).