mirror of
https://github.com/boostorg/functional.git
synced 2025-08-02 14:04:27 +02:00
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<complex>(), although this might lead to users assuming that it can be expected even though it isn't part of the documented interface. [SVN r32780]
This commit is contained in:
@@ -23,6 +23,11 @@ namespace boost
|
|||||||
{
|
{
|
||||||
namespace hash_detail
|
namespace hash_detail
|
||||||
{
|
{
|
||||||
|
inline void hash_float_combine(std::size_t& seed, std::size_t value)
|
||||||
|
{
|
||||||
|
seed ^= value + (seed<<6) + (seed>>2);
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline std::size_t float_hash_value(T v)
|
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<int>::digits);
|
v = boost::hash_detail::call_ldexp(v, std::numeric_limits<int>::digits);
|
||||||
int const part = static_cast<int>(v);
|
int const part = static_cast<int>(v);
|
||||||
v -= part;
|
v -= part;
|
||||||
boost::hash_combine(seed, part);
|
hash_float_combine(seed, part);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::hash_combine(seed, exp);
|
hash_float_combine(seed, exp);
|
||||||
|
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user