From 45eeb170f2b1372b4b5e52744d3c51eddb285b42 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 28 Feb 2016 09:14:37 +0000 Subject: [PATCH] Fix the binary 32 and 64 bit hash functions. --- include/boost/functional/hash/hash.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 3e5ab5b..40954bc 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -212,7 +212,6 @@ namespace boost seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); } - template inline void hash_combine_impl(boost::uint32_t& h1, boost::uint32_t k1) { @@ -234,7 +233,6 @@ namespace boost #if !defined(BOOST_NO_INT64_T) && \ !(defined(__GNUC__) && ULONG_MAX == 0xffffffff) - template inline void hash_combine_impl(boost::uint64_t& h, boost::uint64_t k) { @@ -247,6 +245,10 @@ namespace boost h ^= k; h *= m; + + // Completely arbitrary number, to prevent 0's + // from hashing to 0. + h += 0xe6546b64; } #endif // BOOST_NO_INT64_T