C++基本类型哈希值学习
完全转自: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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步