#ifndef STD_HASH_HPP #define STD_HASH_HPP #include // this is largely inspired by boost's hash combine as can be found in // "The C++ Standard Library" 2nd Edition. Nicolai M. Josuttis. 2012. template void hash_combine(std::size_t &seed, const T &val) { seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } template void hash_val(std::size_t &seed, const T &val) { hash_combine(seed, val); } template void hash_val(std::size_t &seed, const T &val, const Types &... args) { hash_combine(seed, val); hash_val(seed, args...); } template std::size_t hash_val(const Types &... args) { std::size_t seed = 0; hash_val(seed, args...); return seed; } namespace std { template struct hash> { size_t operator()(const std::pair &pair) const { return hash_val(pair.first, pair.second); } }; } #endif // STD_HASH_HPP