std::collate<CharT>::hash,std::collate<CharT>::do_hash (3) - Linux Manuals
std::collate<CharT>::hash,std::collate<CharT>::do_hash: std::collate<CharT>::hash,std::collate<CharT>::do_hash
NAME
std::collate<CharT>::hash,std::collate<CharT>::do_hash - std::collate<CharT>::hash,std::collate<CharT>::do_hash
Synopsis
Defined in header <locale>
public: (1)
long hash( const CharT* beg, const CharT* end ) const;
protected: (2)
virtual long do_hash( const CharT* beg, const CharT* end ) const;
1) Public member function, calls the protected virtual member function do_hash of the most derived class.
2) Converts the character sequence [beg, end) to an integer value that is equal to the hash obtained for all strings that collate equivalent in this locale (compare() returns 0). For two strings that do not collate equivalent, the probability that their hashes are equal should be very small, approaching 1.0/std::numeric_limits<unsigned long>::max().
Parameters
beg - pointer to the first character in the sequence to hash
end - one past the end pointer for the sequence to hash
Return value
The hash value that respects collation order
Note
The system-supplied locales normally do not collate two strings as equivalent (compare() does not return 0) if basic_string::operator== returns false, but a user-installed std::collate facet may provide different collation rules, for example, it may treat strings as equivalent if they have the same Unicode normalized form.
Example
Demonstrates a locale-aware unordered container
// Run this code
Possible output:
See also
std::hash<std::string>
std::hash<std::u8string>
std::hash<std::u16string>
std::hash<std::u32string>
std::hash<std::wstring>
std::hash<std::pmr::string>
std::hash<std::pmr::u8string>
std::hash<std::pmr::u16string>
std::hash<std::pmr::u32string>
std::hash<std::pmr::wstring> hash support for strings