Reputation: 349
The following command produces different results for hashed_data on 2 PCs. The one uses Visual Studio 2010 and the other Visual Studio 2013. Hash should normally give the same results with the same input
hash<string> hash_func;
unsigned long long hashed_data = (unsigned long long)hash_func("dogcat");
The computer with VS 2010 results 6824943158688951155
The computer with VS 2013 results 14899951770080783754
Other inputs produce also different results between the two PCs.
Upvotes: 1
Views: 495
Reputation: 180050
It's always hard to answer a question in the negative, but the basic answer here is that multiple implementations of the Standard Library exist. Their behavior is very, very similar as far as it's documented in the Standard, but exact hash values are not documented. This leaves room for implementation optimization. Since smarter hash functions can lead to more efficient hash tables, it's to be expected that hash functions will differ.
Upvotes: 1