From 7fd7098265f228acc772b940d72cc9a6fabd45b2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 20 Jun 2015 15:04:31 +0100 Subject: [PATCH] Add a combine_hash helper function --- src/hash.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hash.hh b/src/hash.hh index 3fc8abd2..896478f3 100644 --- a/src/hash.hh +++ b/src/hash.hh @@ -31,12 +31,16 @@ 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 seed ^ (hash_value(std::forward(t)) + 0x9e3779b9 + - (seed << 6) + (seed >> 2)); + return combine_hash(seed, hash_value(std::forward(t))); } template