Try to use pair as key value for hash_map under Visual Studio 2010.
Could not compile it.
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;
}
got error message:
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
I know it probably due to hash_map
doesn't provide a specialization for pair
. Any easy way to fix it?
std::map
but notstd::unordered_map
– Benjhash_map
and use a properstd::unordered_map
. Though, this still won't solve your problem. Unfortunately missing hash functions forstd::pair
is one of the biggest oversights in C++11 (but Ok, at least they realized after 15 years that a hash is useful data structure). – Christian Rau