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:
Daniel James
2006-02-09 19:07:33 +00:00
parent 50011103a4
commit 5a5bbbf403

View File

@@ -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 <class T>
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);
int const part = static_cast<int>(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;
}