forked from boostorg/container_hash
Simpler test for appropriate floats for binary hashing. Refs #8822.
No idea if this will actually fix it. [SVN r85246]
This commit is contained in:
@@ -90,15 +90,20 @@ namespace boost
|
||||
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 @@ namespace boost
|
||||
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 @@ namespace boost
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user