Difference between revisions of "cpp/string/basic string view/hash"
From cppreference.com
< cpp | string | basic string view
(+) |
(P0513R0's note on hash equality from strings makes sense here too. Also not applying "The specializations are enabled" where it is redundant (the paper said it's redundant, they are only putting it where it would otherwise leave an empty paragraph)) |
||
Line 12: | Line 12: | ||
Template specializations of {{lc|std::hash}} for the various view classes for hashing views. | Template specializations of {{lc|std::hash}} for the various view classes for hashing views. | ||
+ | |||
+ | {{rev begin}} | ||
+ | {{rev|since=c++17| | ||
+ | These hashes equal the hashes of corresponding {{lc|std::basic_string}} classes: If S is one of the standard basic_string types, SV is the corresponding string view type, and s is an object of type S, then {{c|std::hash<S>()(s) {{==}} std::hash<SV>()(SV(s))}}. | ||
+ | }} | ||
+ | {{rev end}} | ||
===See also=== | ===See also=== |
Revision as of 14:12, 17 November 2016
Defined in header <string_view>
|
||
template<> struct hash<std::string_view>; template<> struct hash<std::wstring_view>; |
(since C++17) | |
Template specializations of std::hash for the various view classes for hashing views.
These hashes equal the hashes of corresponding std::basic_string classes: If S is one of the standard basic_string types, SV is the corresponding string view type, and s is an object of type S, then std::hash<S>()(s) == std::hash<SV>()(SV(s)). |
(since C++17) |
See also
(C++11) |
hash function object (class template) |