尝试在 Visual Studio 2010 下使用 pair 作为 hash_map 的键值。
无法编译。
int _tmain(int argc, _TCHAR* argv[])
{
hash_map <pair<int, int>, int> months;
months[pair<int, int>(2,3)] = 1;
int d;
cin >> d;
return 0;
}
收到错误信息:
Error 1 error C2440: 'type cast' : cannot convert from 'const std::pair<_Ty1,_Ty2>' to 'size_t' c:\program files\microsoft visual studio 10.0\vc\include\xhash 34 1 testApplication1
我知道这可能是因为 hash_map
没有为 pair
提供专门化。有什么简单的方法可以解决吗?
最佳答案
关于c++ - 在 Visual Studio 下使用 pair 作为 hash_map 的键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14878721/