std::hash
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<class T, class Deleter> struct hash<unique_ptr<T, Deleter>>; |
(dal C++11) | |
Il modello di specializzazione di std::hash per
std::unique_ptr<T, Deleter> consente agli utenti di ottenere gli hash di oggetti di tipo std::unique_ptr<T, Deleter>.Original:
The template specialization of std::hash for
std::unique_ptr<T, Deleter> allows users to obtain hashes of objects of type std::unique_ptr<T, Deleter>.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.
Per un dato
std::unique_ptr<T, Deleter> p, questa specializzazione assicura che std::hash<std::unique_ptr<T, Deleter>>()(p) == std::hash<T*>()(p.get()).Original:
For a given
std::unique_ptr<T, Deleter> p, this specialization ensures that std::hash<std::unique_ptr<T, Deleter>>()(p) == std::hash<T*>()(p.get()).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
#include <iostream>
#include <memory>
#include <functional>
struct Foo {
Foo() { std::cout << "Foo...\n"; }
~Foo() { std::cout << "~Foo...\n\n"; }
};
int main()
{
Foo* foo = new Foo();
std::unique_ptr<Foo> up(foo);
std::cout << "hash(up): " << std::hash<std::unique_ptr<Foo>>()(up) << '\n';
std::cout << "hash(foo): " << std::hash<Foo*>()(foo) << '\n';
}
Output:
Foo...
hash(up): 3686401041
hash(foo): 3686401041
~Foo...
Vedi anche
(C++11) |
hash function object (classe template) |