Skip to content

Commit

Permalink
Fix: add workaround for boost versions >=1.84.0 (HarbourMasters#4098)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored May 1, 2024
1 parent 4a576f4 commit fd9cd9c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
15 changes: 13 additions & 2 deletions soh/include/boost_custom/container_hash/detail/hash_range_32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,18 @@ template<> struct is_char_type<std::byte>: 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<class It>
inline typename boost::enable_if_<
inline typename BOOST_ENABLE_IF<
is_char_type<typename std::iterator_traits<It>::value_type>::value &&
is_same<typename std::iterator_traits<It>::iterator_category, std::random_access_iterator_tag>::value,
BOOST_IS_SAME<typename std::iterator_traits<It>::iterator_category, std::random_access_iterator_tag>::value,
std::size_t>::type
hash_range_32( uint32_t seed, It first, It last )
{
Expand Down Expand Up @@ -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
24 changes: 20 additions & 4 deletions soh/include/boost_custom/container_hash/hash_32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand All @@ -36,7 +48,7 @@ namespace boost
{
template<class T,
bool bigger_than_size_t = (sizeof(T) > sizeof(uint32_t)),
bool is_unsigned = boost::is_unsigned<T>::value,
bool is_unsigned = BOOST_IS_UNSIGNED<T>::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;
Expand All @@ -53,7 +65,7 @@ namespace boost
{
static uint32_t fn( T v )
{
typedef typename boost::make_unsigned<T>::type U;
typedef typename BOOST_MAKE_UNSIGNED<T>::type U;

if( v >= 0 )
{
Expand Down Expand Up @@ -97,7 +109,7 @@ namespace boost
} // namespace hash_detail

template <typename T>
typename boost::enable_if_<boost::is_integral<T>::value, uint32_t>::type
typename BOOST_ENABLE_IF<BOOST_IS_INTEGRAL<T>::value, uint32_t>::type
hash_value_32( T v )
{
return hash_detail::hash_integral_impl_32<T>::fn( v );
Expand All @@ -106,7 +118,7 @@ namespace boost
// contiguous ranges (string, vector, array)
#if BOOST_VERSION_HAS_HASH_RANGE
template <typename T>
typename boost::enable_if_<container_hash::is_contiguous_range<T>::value, uint32_t>::type
typename BOOST_ENABLE_IF<container_hash::is_contiguous_range<T>::value, uint32_t>::type
hash_value_32( T const& v )
{
return boost::hash_range_32( v.data(), v.data() + v.size() );
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions soh/include/boost_custom/container_hash/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fd9cd9c

Please sign in to comment.