std::hash (std::string, std::wstring, std::u16string, std::u32string)
Da cppreference.com.
< cpp | string | basic string
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <string>
|
||
template<> struct hash<std::string>; template<> struct hash<std::wstring>; |
(dal C++11) | |
The template specializations of std::hash for the various string classes allow users to obtain hashes of strings.
[modifica] Esempio
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'; }
Output:
325378910
[modifica] Vedi anche
(C++11) |
hash function object (classe template) |