C++ STL provides template specializations of std::hash
for the various string classes. You could just specify std::string
as key type for std::unordered_map
:
#include <string>
#include <unordered_map>
int main()
{
std::unordered_map<std::string, int> map;
map["string"] = 10;
return 0;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…