Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85246 - trunk/boost/functional/hash/detail
From: dnljms_at_[hidden]
Date: 2013-08-08 16:30:05


Author: danieljames
Date: 2013-08-08 16:30:04 EDT (Thu, 08 Aug 2013)
New Revision: 85246
URL: http://svn.boost.org/trac/boost/changeset/85246

Log:
Simpler test for appropriate floats for binary hashing. Refs #8822.

No idea if this will actually fix it.

Text files modified:
   trunk/boost/functional/hash/detail/hash_float.hpp | 31 +++++++++++++------------------
   1 files changed, 13 insertions(+), 18 deletions(-)

Modified: trunk/boost/functional/hash/detail/hash_float.hpp
==============================================================================
--- trunk/boost/functional/hash/detail/hash_float.hpp Thu Aug 8 16:28:53 2013 (r85245)
+++ trunk/boost/functional/hash/detail/hash_float.hpp 2013-08-08 16:30:04 EDT (Thu, 08 Aug 2013) (r85246)
@@ -90,15 +90,20 @@
             return seed;
         }
 
+ template <typename Float, unsigned digits, unsigned max_exponent>
+ struct enable_binary_hash
+ {
+ BOOST_STATIC_CONSTANT(bool, value =
+ std::numeric_limits<Float>::is_iec559 &&
+ std::numeric_limits<Float>::digits == digits &&
+ std::numeric_limits<Float>::radix == 2 &&
+ std::numeric_limits<Float>::max_exponent == max_exponent);
+ };
+
         template <typename Float>
         inline std::size_t float_hash_impl(Float v,
             BOOST_DEDUCED_TYPENAME boost::enable_if_c<
- std::numeric_limits<Float>::is_iec559 &&
- std::numeric_limits<Float>::digits == 24 &&
- std::numeric_limits<Float>::radix == 2 &&
- std::numeric_limits<Float>::max_exponent == 128,
- int>::type
- )
+ enable_binary_hash<Float, 24, 128>::value, int>::type)
         {
             return hash_binary((char*) &v, 4);
         }
@@ -107,12 +112,7 @@
         template <typename Float>
         inline std::size_t float_hash_impl(Float v,
             BOOST_DEDUCED_TYPENAME boost::enable_if_c<
- std::numeric_limits<Float>::is_iec559 &&
- std::numeric_limits<Float>::digits == 53 &&
- std::numeric_limits<Float>::radix == 2 &&
- std::numeric_limits<Float>::max_exponent == 1024,
- int>::type
- )
+ enable_binary_hash<Float, 53, 1024>::value, int>::type)
         {
             return hash_binary((char*) &v, 8);
         }
@@ -120,12 +120,7 @@
         template <typename Float>
         inline std::size_t float_hash_impl(Float v,
             BOOST_DEDUCED_TYPENAME boost::enable_if_c<
- std::numeric_limits<Float>::is_iec559 &&
- std::numeric_limits<Float>::digits == 64 &&
- std::numeric_limits<Float>::radix == 2 &&
- std::numeric_limits<Float>::max_exponent == 16384,
- int>::type
- )
+ enable_binary_hash<Float, 64, 16384>::value, int>::type)
         {
             return hash_binary((char*) &v, 10);
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk