std::hash (std::string, std::wstring, std::u16string, std::u32string)
提供: cppreference.com
< cpp | string | basic string
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <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) | ハッシュ関数オブジェクト (クラステンプレート) |