std::hash (std::bitset)
Da cppreference.com.
|
|
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. |
<metanoindex/>
<tbody> </tbody> template<size_t N> struct hash<bitset<N>>; |
(dal C++11) | |
Il modello di specializzazione di std::hash per
std::bitset<N> consente agli utenti di ottenere gli hash di oggetti di tipo std::bitset<N>.Original:
The template specialization of std::hash for
std::bitset<N> allows users to obtain hashes of objects of type std::bitset<N>.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Esempio
Il codice seguente mostra una possibile uscita di una funzione di hash utilizzato su bitset diversi:
Original:
The following code shows one possible output of a hash function used on several bitsets:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>
#include <bitset>
#include <functional>
int main()
{
std::bitset<4> b1(1);
std::bitset<4> b2(2);
std::bitset<4> b3(b2);
std::hash<std::bitset<4>> hash_fn;
size_t h1 = hash_fn(b1);
size_t h2 = hash_fn(b2);
size_t h3 = hash_fn(b3);
std::cout << h1 << '\n';
std::cout << h2 << '\n';
std::cout << h3 << '\n';
}
Output:
67918732
118251589
118251589
Vedi anche
(C++11) |
hash function object (classe template) |