From 534d526c90d78f0d5aad501b3ce3f9f0f5e9e15c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 9 Feb 2006 19:07:33 +0000 Subject: [PATCH] Make hash_float.hpp use its own combine function. This serves two purposes: 1. hash_float is no longer dependent on the main hash header. 2. hash_float(0) == 0 which makes it easier to implement hash(), although this might lead to users assuming that it can be expected even though it isn't part of the documented interface. [SVN r32780] --- include/boost/functional/detail/hash_float.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/boost/functional/detail/hash_float.hpp b/include/boost/functional/detail/hash_float.hpp index cc9fd51..f6cb204 100644 --- a/include/boost/functional/detail/hash_float.hpp +++ b/include/boost/functional/detail/hash_float.hpp @@ -23,6 +23,11 @@ namespace boost { namespace hash_detail { + inline void hash_float_combine(std::size_t& seed, std::size_t value) + { + seed ^= value + (seed<<6) + (seed>>2); + } + template inline std::size_t float_hash_value(T v) { @@ -43,10 +48,10 @@ namespace boost v = boost::hash_detail::call_ldexp(v, std::numeric_limits::digits); int const part = static_cast(v); v -= part; - boost::hash_combine(seed, part); + hash_float_combine(seed, part); } - boost::hash_combine(seed, exp); + hash_float_combine(seed, exp); return seed; }