From fa6451514037787cbf69c2a3ed3e0aeae3a63bdf Mon Sep 17 00:00:00 2001 From: Wojciech Mamrak Date: Sat, 23 Mar 2019 02:26:04 +0100 Subject: [PATCH] Improved 32 bit compilation The fix removes the warnings when using Visual Studio 2017 --- flat_hash_map.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/flat_hash_map.hpp b/flat_hash_map.hpp index 3cdd34b..b0019ed 100644 --- a/flat_hash_map.hpp +++ b/flat_hash_map.hpp @@ -1316,7 +1316,11 @@ struct fibonacci_hash_policy { size_t index_for_hash(size_t hash, size_t /*num_slots_minus_one*/) const { +#ifdef ENV64BIT return (11400714819323198485ull * hash) >> shift; +#else + return (2654435769u * hash) >> shift; +#endif } size_t keep_in_range(size_t index, size_t num_slots_minus_one) const { @@ -1326,7 +1330,7 @@ struct fibonacci_hash_policy int8_t next_size_over(size_t & size) const { size = std::max(size_t(2), detailv3::next_power_of_two(size)); - return 64 - detailv3::log2(size); + return sizeof(size_t) * CHAR_BIT - detailv3::log2(size); } void commit(int8_t shift) { @@ -1334,11 +1338,11 @@ struct fibonacci_hash_policy } void reset() { - shift = 63; + shift = sizeof(size_t) * CHAR_BIT - 1; } private: - int8_t shift = 63; + int8_t shift = sizeof(size_t) * CHAR_BIT - 1; }; template, typename E = std::equal_to, typename A = std::allocator > >