From b58f7ea8b63ecf442893bd50eb126d9eced7e82a Mon Sep 17 00:00:00 2001 From: Archez Date: Wed, 1 May 2024 16:41:17 -0400 Subject: [PATCH] Fix: add workaround for boost versions >=1.84.0 (#4098) --- .../container_hash/detail/hash_range_32.hpp | 15 ++++++++++-- .../boost_custom/container_hash/hash_32.hpp | 24 +++++++++++++++---- .../boost_custom/container_hash/version.hpp | 2 ++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp b/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp index 7430152ab66..cfa0a2a2d20 100644 --- a/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp +++ b/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp @@ -46,10 +46,18 @@ template<> struct is_char_type: public boost::true_type {}; #endif // #if !BOOST_VERSION_HAS_HASH_RANGE +#if BOOST_USE_STD_TYPES +#define BOOST_ENABLE_IF std::enable_if +#define BOOST_IS_SAME std::is_same +#else +#define BOOST_ENABLE_IF boost::enable_if_ +#define BOOST_IS_SAME is_same +#endif + template -inline typename boost::enable_if_< +inline typename BOOST_ENABLE_IF< is_char_type::value_type>::value && - is_same::iterator_category, std::random_access_iterator_tag>::value, + BOOST_IS_SAME::iterator_category, std::random_access_iterator_tag>::value, std::size_t>::type hash_range_32( uint32_t seed, It first, It last ) { @@ -114,4 +122,7 @@ std::size_t>::type } // namespace hash_detail } // namespace boost +#undef BOOST_ENABLE_IF +#undef BOOST_IS_SAME + #endif // #ifndef BOOST_HASH_DETAIL_HASH_RANGE_32_HPP diff --git a/soh/include/boost_custom/container_hash/hash_32.hpp b/soh/include/boost_custom/container_hash/hash_32.hpp index 4b955c43a02..eaf459a3439 100644 --- a/soh/include/boost_custom/container_hash/hash_32.hpp +++ b/soh/include/boost_custom/container_hash/hash_32.hpp @@ -23,6 +23,18 @@ #endif // #if !BOOST_VERSION_HAS_HASH_RANGE +#if BOOST_USE_STD_TYPES +#define BOOST_ENABLE_IF std::enable_if +#define BOOST_IS_INTEGRAL hash_detail::is_integral +#define BOOST_IS_UNSIGNED is_unsigned +#define BOOST_MAKE_UNSIGNED make_unsigned +#else +#define BOOST_ENABLE_IF boost::enable_if_ +#define BOOST_IS_INTEGRAL boost::is_integral +#define BOOST_IS_UNSIGNED boost::is_unsigned +#define BOOST_MAKE_UNSIGNED boost::make_unsigned +#endif + namespace boost { @@ -36,7 +48,7 @@ namespace boost { template sizeof(uint32_t)), - bool is_unsigned = boost::is_unsigned::value, + bool is_unsigned = BOOST_IS_UNSIGNED::value, std::size_t size_t_bits = sizeof(uint32_t) * CHAR_BIT, std::size_t type_bits = sizeof(T) * CHAR_BIT> struct hash_integral_impl_32; @@ -53,7 +65,7 @@ namespace boost { static uint32_t fn( T v ) { - typedef typename boost::make_unsigned::type U; + typedef typename BOOST_MAKE_UNSIGNED::type U; if( v >= 0 ) { @@ -97,7 +109,7 @@ namespace boost } // namespace hash_detail template - typename boost::enable_if_::value, uint32_t>::type + typename BOOST_ENABLE_IF::value, uint32_t>::type hash_value_32( T v ) { return hash_detail::hash_integral_impl_32::fn( v ); @@ -106,7 +118,7 @@ namespace boost // contiguous ranges (string, vector, array) #if BOOST_VERSION_HAS_HASH_RANGE template - typename boost::enable_if_::value, uint32_t>::type + typename BOOST_ENABLE_IF::value, uint32_t>::type hash_value_32( T const& v ) { return boost::hash_range_32( v.data(), v.data() + v.size() ); @@ -168,5 +180,9 @@ namespace boost } // namespace boost #undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_ENABLE_IF +#undef BOOST_IS_INTEGRAL +#undef BOOST_IS_UNSIGNED +#undef BOOST_MAKE_UNSIGNED #endif // #ifndef BOOST_FUNCTIONAL_HASH_HASH_32_HPP diff --git a/soh/include/boost_custom/container_hash/version.hpp b/soh/include/boost_custom/container_hash/version.hpp index 22ad6634cfc..3863b507c87 100644 --- a/soh/include/boost_custom/container_hash/version.hpp +++ b/soh/include/boost_custom/container_hash/version.hpp @@ -6,4 +6,6 @@ #define BOOST_VERSION_HAS_HASH_RANGE ((BOOST_VERSION / 100 % 1000) >= 81) +#define BOOST_USE_STD_TYPES ((BOOST_VERSION / 100 % 1000) >= 84) + #endif // #ifndef BOOST_CONTAINER_HASH_VERSION_HPP