#ifndef hash_hh_INCLUDED #define hash_hh_INCLUDED #include #include #include namespace Kakoune { size_t hash_data(const char* data, size_t len); template size_t hash_value(const Type&... val) { static_assert(sizeof...(Type) == 1, ""); return std::hash()(val...); } template typename std::enable_if::value, size_t>::type hash_value(const Type& val) { return hash_value((typename std::underlying_type::type)val); } template size_t hash_values(Type&& t) { return hash_value(std::forward(t)); } inline size_t combine_hash(size_t lhs, size_t rhs) { return lhs ^ (rhs + 0x9e3779b9 + (lhs << 6) + (lhs >> 2)); } template size_t hash_values(Type&& t, RemainingTypes&&... rt) { size_t seed = hash_values(std::forward(rt)...); return combine_hash(seed, hash_value(std::forward(t))); } template size_t hash_value(const std::pair& val) { return hash_values(val.first, val.second); } template struct Hash { size_t operator()(const Type& val) const { return hash_value(val); } }; } #endif // hash_hh_INCLUDED