From 5ba74cd3a98fe7bd9b8a7d47b7998290757a3235 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 3 Jul 2022 23:35:46 +0300 Subject: [PATCH] Update hash_value for pointers to handle the case when uintptr_t is larger than size_t --- include/boost/container_hash/hash.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index f58c9c8..b9dbf8e 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -344,12 +344,11 @@ namespace boost // pointer types - // Implementation by Alberto Barbati and Dave Harris. + // `x + (x >> 3)` adjustment by Alberto Barbati and Dave Harris. template std::size_t hash_value( T* const& v ) { - std::size_t x = static_cast( - reinterpret_cast(v)); - return x + (x >> 3); + boost::uintptr_t x = reinterpret_cast( v ); + return boost::hash_value( x + (x >> 3) ); } // array types