From aaa1f441ac937a1470203862d3117631621f478d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 17 Oct 2021 16:17:44 +0300 Subject: [PATCH] GCC 32 bit under Windows has an 80 bit long double in 12 bytes, not 16 --- include/boost/container_hash/hash.hpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index c52cd6b..f245642 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -150,7 +150,24 @@ namespace boost } }; - // 80 bit long double + // 80 bit long double in 12 bytes + template struct hash_float_impl + { + static std::size_t fn( T v ) + { + boost::uint64_t w[ 2 ] = {}; + std::memcpy( &w, &v, 80 / CHAR_BIT ); + + std::size_t seed = 0; + + boost::hash_combine( seed, w[ 0 ] ); + boost::hash_combine( seed, w[ 1 ] ); + + return seed; + } + }; + + // 80 bit long double in 16 bytes template struct hash_float_impl { static std::size_t fn( T v )