std::hash (std::string, std::wstring, std::u16string, std::u32string)
来自cppreference.com
< cpp | string | basic string
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <string> 中定义
|
||
template<> struct hash<std::string>; template<> struct hash<std::wstring>; |
(C++11 起) | |
The template specializations of std::hash for the various string classes allow users to obtain hashes of strings.
[编辑] 示例
The following code shows one possible output of a hash function used on a string:
#include <iostream> #include <string> #include <functional> int main() { std::string s = "Stand back! I've got jimmies!"; std::hash<std::string> hash_fn; size_t hash = hash_fn(s); std::cout << hash << '\n'; }
输出:
325378910
[编辑] 另请参阅
(C++11) |
hash function object (类模板) |