#ifndef STD_HASH_HPP #define STD_HASH_HPP #include #include #include #include #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_range(std::size_t &seed, It first, const It last) { for (; first != last; ++first) { hash_combine(seed, *first); } } 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> { template static auto apply_tuple(const std::tuple &t, std::index_sequence) { std::size_t seed = 0; return ((seed = hash_val(std::get(t), seed)), ...); } auto operator()(const std::tuple &t) const { return apply_tuple(t, std::make_index_sequence()); } }; template struct hash> { std::size_t operator()(const std::pair &pair) const { return hash_val(pair.first, pair.second); } }; template struct hash> { auto operator()(const std::vector &lane_description) const { std::size_t seed = 0; hash_range(seed, lane_description.begin(), lane_description.end()); return seed; } }; } // namespace std #endif // STD_HASH_HPP