From 670e7b3736d8c7cba1cb640d98dc7d9b1f023788 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 8 Aug 2013 20:30:04 +0000 Subject: [PATCH] Simpler test for appropriate floats for binary hashing. Refs #8822. No idea if this will actually fix it. [SVN r85246] --- .../functional/hash/detail/hash_float.hpp | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index a98cd70..2ac22da 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -90,15 +90,20 @@ namespace boost return seed; } + template + struct enable_binary_hash + { + BOOST_STATIC_CONSTANT(bool, value = + std::numeric_limits::is_iec559 && + std::numeric_limits::digits == digits && + std::numeric_limits::radix == 2 && + std::numeric_limits::max_exponent == max_exponent); + }; + template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 24 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 128, - int>::type - ) + enable_binary_hash::value, int>::type) { return hash_binary((char*) &v, 4); } @@ -107,12 +112,7 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 53 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 1024, - int>::type - ) + enable_binary_hash::value, int>::type) { return hash_binary((char*) &v, 8); } @@ -120,12 +120,7 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 64 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 16384, - int>::type - ) + enable_binary_hash::value, int>::type) { return hash_binary((char*) &v, 10); }