Skip to content

Commit

Permalink
Update to boost 1.85
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed May 11, 2024
1 parent 06ea0c1 commit 92c8d81
Show file tree
Hide file tree
Showing 49 changed files with 6,096 additions and 3,426 deletions.
5,034 changes: 3,168 additions & 1,866 deletions boost_unordered.hpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions include/boost/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )

#include <boost/minconfig.hpp> // for BOOST_LIKELY
#include <boost/current_function.hpp>

namespace boost
Expand Down
14 changes: 10 additions & 4 deletions include/boost/assert/source_location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/current_function.hpp>
#include <boost/minconfig.hpp>
#include <iosfwd>
#include <string>
#include <cstdint>
#include <cstdio>
#include <cstring>

Expand Down Expand Up @@ -144,6 +143,10 @@ template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ost

# define BOOST_CURRENT_LOCATION ::boost::source_location()

#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1935

# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCSIG(), __builtin_COLUMN())

#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926

// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce
Expand All @@ -159,11 +162,14 @@ template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ost

# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "")

#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L
#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && !defined(__NVCC__)

// Under nvcc, __builtin_source_location is not constexpr
// https://github.com/boostorg/assert/issues/32

# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current())

#elif defined(BOOST_CLANG)
#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000

# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN())

Expand Down
146 changes: 146 additions & 0 deletions include/boost/container_hash/detail/hash_integral.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Copyright 2021-2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#ifndef BOOST_HASH_DETAIL_HASH_INTEGRAL_HPP
#define BOOST_HASH_DETAIL_HASH_INTEGRAL_HPP

#include <boost/container_hash/detail/hash_mix.hpp>
#include <type_traits>
#include <cstddef>
#include <climits>

namespace boost
{
namespace hash_detail
{

// libstdc++ doesn't provide support for __int128 in the standard traits

template<class T> struct is_integral: public std::is_integral<T>
{
};

template<class T> struct is_unsigned: public std::is_unsigned<T>
{
};

template<class T> struct make_unsigned: public std::make_unsigned<T>
{
};

#if defined(__SIZEOF_INT128__)

template<> struct is_integral<__int128_t>: public std::true_type
{
};

template<> struct is_integral<__uint128_t>: public std::true_type
{
};

template<> struct is_unsigned<__int128_t>: public std::false_type
{
};

template<> struct is_unsigned<__uint128_t>: public std::true_type
{
};

template<> struct make_unsigned<__int128_t>
{
typedef __uint128_t type;
};

template<> struct make_unsigned<__uint128_t>
{
typedef __uint128_t type;
};

#endif

template<class T,
bool bigger_than_size_t = (sizeof(T) > sizeof(std::size_t)),
bool is_unsigned = is_unsigned<T>::value,
std::size_t size_t_bits = sizeof(std::size_t) * CHAR_BIT,
std::size_t type_bits = sizeof(T) * CHAR_BIT>
struct hash_integral_impl;

template<class T, bool is_unsigned, std::size_t size_t_bits, std::size_t type_bits> struct hash_integral_impl<T, false, is_unsigned, size_t_bits, type_bits>
{
static std::size_t fn( T v )
{
return static_cast<std::size_t>( v );
}
};

template<class T, std::size_t size_t_bits, std::size_t type_bits> struct hash_integral_impl<T, true, false, size_t_bits, type_bits>
{
static std::size_t fn( T v )
{
typedef typename make_unsigned<T>::type U;

if( v >= 0 )
{
return hash_integral_impl<U>::fn( static_cast<U>( v ) );
}
else
{
return ~hash_integral_impl<U>::fn( static_cast<U>( ~static_cast<U>( v ) ) );
}
}
};

template<class T> struct hash_integral_impl<T, true, true, 32, 64>
{
static std::size_t fn( T v )
{
std::size_t seed = 0;

seed = static_cast<std::size_t>( v >> 32 ) + hash_detail::hash_mix( seed );
seed = static_cast<std::size_t>( v & 0xFFFFFFFF ) + hash_detail::hash_mix( seed );

return seed;
}
};

template<class T> struct hash_integral_impl<T, true, true, 32, 128>
{
static std::size_t fn( T v )
{
std::size_t seed = 0;

seed = static_cast<std::size_t>( v >> 96 ) + hash_detail::hash_mix( seed );
seed = static_cast<std::size_t>( v >> 64 ) + hash_detail::hash_mix( seed );
seed = static_cast<std::size_t>( v >> 32 ) + hash_detail::hash_mix( seed );
seed = static_cast<std::size_t>( v ) + hash_detail::hash_mix( seed );

return seed;
}
};

template<class T> struct hash_integral_impl<T, true, true, 64, 128>
{
static std::size_t fn( T v )
{
std::size_t seed = 0;

seed = static_cast<std::size_t>( v >> 64 ) + hash_detail::hash_mix( seed );
seed = static_cast<std::size_t>( v ) + hash_detail::hash_mix( seed );

return seed;
}
};

} // namespace hash_detail

template <typename T>
typename std::enable_if<hash_detail::is_integral<T>::value, std::size_t>::type
hash_value( T v )
{
return hash_detail::hash_integral_impl<T>::fn( v );
}

} // namespace boost

#endif // #ifndef BOOST_HASH_DETAIL_HASH_INTEGRAL_HPP
3 changes: 2 additions & 1 deletion include/boost/container_hash/detail/hash_mix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BOOST_HASH_DETAIL_HASH_MIX_HPP
#define BOOST_HASH_DETAIL_HASH_MIX_HPP

#include <cstdint>
#include <cstddef>
#include <climits>

Expand Down Expand Up @@ -67,7 +68,7 @@ template<> struct hash_mix_impl<64>
{
inline static std::uint64_t fn( std::uint64_t x )
{
std::uint64_t const m = (std::uint64_t(0xe9846af) << 32) + 0x9b1a615d;
std::uint64_t const m = 0xe9846af9b1a615d;

x ^= x >> 32;
x *= m;
Expand Down
10 changes: 6 additions & 4 deletions include/boost/container_hash/detail/hash_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <boost/container_hash/hash_fwd.hpp>
#include <boost/container_hash/detail/mulx.hpp>
#include <type_traits>
#include <cstdint>
#include <iterator>
#include <limits>
#include <cstddef>
Expand Down Expand Up @@ -252,8 +254,8 @@ std::size_t>::type
It p = first;
std::size_t n = static_cast<std::size_t>( last - first );

std::uint64_t const q = static_cast<std::uint64_t>( 0x9e3779b9 ) << 32 | 0x7f4a7c15;
std::uint64_t const k = static_cast<std::uint64_t>( 0xdf442d22 ) << 32 | 0xce4859b9; // q * q
std::uint64_t const q = 0x9e3779b97f4a7c15;
std::uint64_t const k = 0xdf442d22ce4859b9; // q * q

std::uint64_t w = mulx( seed + q, k );
std::uint64_t h = w ^ n;
Expand Down Expand Up @@ -304,8 +306,8 @@ std::size_t>::type
{
std::size_t n = 0;

std::uint64_t const q = static_cast<std::uint64_t>( 0x9e3779b9 ) << 32 | 0x7f4a7c15;
std::uint64_t const k = static_cast<std::uint64_t>( 0xdf442d22 ) << 32 | 0xce4859b9; // q * q
std::uint64_t const q = 0x9e3779b97f4a7c15;
std::uint64_t const k = 0xdf442d22ce4859b9; // q * q

std::uint64_t w = mulx( seed + q, k );
std::uint64_t h = w;
Expand Down
10 changes: 2 additions & 8 deletions include/boost/container_hash/detail/hash_tuple_like.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
#include <boost/container_hash/hash_fwd.hpp>
#include <boost/container_hash/is_tuple_like.hpp>
#include <boost/container_hash/is_range.hpp>


#include <tuple>
#include <type_traits>
#include <utility>

namespace boost
{
Expand Down Expand Up @@ -48,8 +47,6 @@ inline std::size_t hash_tuple_like( T const& v )

} // namespace hash_detail



template <class T>
inline
typename std::enable_if<
Expand All @@ -60,9 +57,6 @@ std::size_t>::type
return boost::hash_detail::hash_tuple_like( v );
}



} // namespace boost


#endif // #ifndef BOOST_HASH_DETAIL_HASH_TUPLE_LIKE_HPP
1 change: 1 addition & 0 deletions include/boost/container_hash/detail/mulx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BOOST_HASH_DETAIL_MULX_HPP
#define BOOST_HASH_DETAIL_MULX_HPP

#include <cstdint>
#if defined(_MSC_VER)
# include <intrin.h>
#endif
Expand Down
Loading

0 comments on commit 92c8d81

Please sign in to comment.