Hash Value Combination in C 0x
In C 0x, the addition of hash<...>(...) introduces a valuable tool for manipulating hash values. However, the absence of a hash_combine function similar to that provided in Boost has left programmers seeking an alternative approach. This article explores a clean implementation using C 0x's xor_combine.
The crux of the solution lies in imitating the implementation from Boost:
template <class T> inline void hash_combine(std::size_t& seed, const T& v) { std::hash<T> hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); }
This function employs std::hash
The above is the detailed content of How Can I Effectively Combine Hash Values in C 0x?. For more information, please follow other related articles on the PHP Chinese website!