完全轉自:https://blog.csdn.net/liyazhen2011/article/details/100181869
1.例子
#include <iostream> #include <string> using namespace std; int main() { cout << "hash value = " << hash<int>()(123) << endl; cout << "hash value = " << hash<long>()(123L) << endl; cout << "hash value = " << hash<string>()("April") << endl; cout << "hash value = " << hash<const char*>()("April") << endl; cout << "hash value = " << hash<char>()('A') << endl; cout << "hash value = " << hash<float>()(3.141592653) << endl; cout << "hash value = " << hash<double>()(3.141592653) << endl; } // 執行結果: hash value = 123 hash value = 123 hash value = 3873163312835782020 hash value = 14878092512267864660 hash value = 65 hash value = 1078530011 hash value = 4614256656550717752