diff options
Diffstat (limited to 'boost/functional/hash/detail/hash_float.hpp')
-rw-r--r-- | boost/functional/hash/detail/hash_float.hpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/boost/functional/hash/detail/hash_float.hpp b/boost/functional/hash/detail/hash_float.hpp index ea1bc25f48..194be1cae5 100644 --- a/boost/functional/hash/detail/hash_float.hpp +++ b/boost/functional/hash/detail/hash_float.hpp @@ -87,9 +87,23 @@ namespace boost namespace hash_detail { template <class T> + inline bool is_zero(T v) + { +#if !defined(__GNUC__) + return v == 0; +#else + // GCC's '-Wfloat-equal' will complain about comparing + // v to 0, but because it disables warnings for system + // headers it won't complain if you use std::equal_to to + // compare with 0. Resulting in this silliness: + return std::equal_to<T>()(v, 0); +#endif + } + + template <class T> inline std::size_t float_hash_value(T v) { - return v == 0 ? 0 : float_hash_impl(v); + return boost::hash_detail::is_zero(v) ? 0 : float_hash_impl(v); } } } |