diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-06 23:31:35 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-06 23:31:35 +0300 |
commit | 4535a1bf240da81a775d25fd3f152020f96a5b63 (patch) | |
tree | 073dc8bf5fe1ecfa40bcb0698ab63dc370924045 | |
parent | 70baf158abf286f22e94c698595e2be355066d11 (diff) | |
download | ydb-4535a1bf240da81a775d25fd3f152020f96a5b63.tar.gz |
Update contrib/restricted/boost/integer to 1.79.0
12 files changed, 772 insertions, 138 deletions
diff --git a/contrib/restricted/boost/core/include/boost/core/bit.hpp b/contrib/restricted/boost/core/include/boost/core/bit.hpp new file mode 100644 index 00000000000..12889790918 --- /dev/null +++ b/contrib/restricted/boost/core/include/boost/core/bit.hpp @@ -0,0 +1,595 @@ +#ifndef BOOST_CORE_BIT_HPP_INCLUDED +#define BOOST_CORE_BIT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// boost/core/bit.hpp +// +// A portable version of the C++20 standard header <bit> +// +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/config.hpp> +#include <boost/static_assert.hpp> +#include <boost/cstdint.hpp> +#include <limits> +#include <cstring> + +#if defined(_MSC_VER) + +# include <intrin.h> +# pragma intrinsic(_BitScanForward) +# pragma intrinsic(_BitScanReverse) + +# if defined(_M_X64) +# pragma intrinsic(_BitScanForward64) +# pragma intrinsic(_BitScanReverse64) +# endif + +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +# pragma warning(disable: 4244) // conversion from int to T + +#endif // defined(_MSC_VER) + +namespace boost +{ +namespace core +{ + +// bit_cast + +template<class To, class From> +To bit_cast( From const & from ) BOOST_NOEXCEPT +{ + BOOST_STATIC_ASSERT( sizeof(To) == sizeof(From) ); + + To to; + std::memcpy( &to, &from, sizeof(To) ); + return to; +} + +// countl + +#if defined(__GNUC__) || defined(__clang__) + +namespace detail +{ + +BOOST_CONSTEXPR inline int countl_impl( unsigned char x ) BOOST_NOEXCEPT +{ + return x? __builtin_clz( x ) - ( std::numeric_limits<unsigned int>::digits - std::numeric_limits<unsigned char>::digits ): std::numeric_limits<unsigned char>::digits; +} + +BOOST_CONSTEXPR inline int countl_impl( unsigned short x ) BOOST_NOEXCEPT +{ + return x? __builtin_clz( x ) - ( std::numeric_limits<unsigned int>::digits - std::numeric_limits<unsigned short>::digits ): std::numeric_limits<unsigned short>::digits; +} + +BOOST_CONSTEXPR inline int countl_impl( unsigned int x ) BOOST_NOEXCEPT +{ + return x? __builtin_clz( x ): std::numeric_limits<unsigned int>::digits; +} + +BOOST_CONSTEXPR inline int countl_impl( unsigned long x ) BOOST_NOEXCEPT +{ + return x? __builtin_clzl( x ): std::numeric_limits<unsigned long>::digits; +} + +BOOST_CONSTEXPR inline int countl_impl( boost::ulong_long_type x ) BOOST_NOEXCEPT +{ + return x? __builtin_clzll( x ): std::numeric_limits<boost::ulong_long_type>::digits; +} + +} // namespace detail + +template<class T> +BOOST_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT +{ + return boost::core::detail::countl_impl( x ); +} + +#else // defined(__GNUC__) || defined(__clang__) + +namespace detail +{ + +inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT +{ +#if defined(_MSC_VER) + + unsigned long r; + + if( _BitScanReverse( &r, x ) ) + { + return 31 - static_cast<int>( r ); + } + else + { + return 32; + } + +#else + + static unsigned char const mod37[ 37 ] = { 32, 31, 6, 30, 9, 5, 0, 29, 16, 8, 2, 4, 21, 0, 19, 28, 25, 15, 0, 7, 10, 1, 17, 3, 22, 20, 26, 0, 11, 18, 23, 27, 12, 24, 13, 14, 0 }; + + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + + return mod37[ x % 37 ]; + +#endif +} + +inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT +{ +#if defined(_MSC_VER) && defined(_M_X64) + + unsigned long r; + + if( _BitScanReverse64( &r, x ) ) + { + return 63 - static_cast<int>( r ); + } + else + { + return 64; + } + +#else + + return static_cast<boost::uint32_t>( x >> 32 ) != 0? + boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ): + boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32; + +#endif +} + +inline int countl_impl( boost::uint8_t x ) BOOST_NOEXCEPT +{ + return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 24; +} + +inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT +{ + return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 16; +} + +} // namespace detail + +template<class T> +int countl_zero( T x ) BOOST_NOEXCEPT +{ + BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) ); + + if( sizeof(T) == sizeof(boost::uint8_t) ) + { + return boost::core::detail::countl_impl( static_cast<boost::uint8_t>( x ) ); + } + else if( sizeof(T) == sizeof(boost::uint16_t) ) + { + return boost::core::detail::countl_impl( static_cast<boost::uint16_t>( x ) ); + } + else if( sizeof(T) == sizeof(boost::uint32_t) ) + { + return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ); + } + else + { + return boost::core::detail::countl_impl( static_cast<boost::uint64_t>( x ) ); + } +} + +#endif // defined(__GNUC__) || defined(__clang__) + +template<class T> +BOOST_CONSTEXPR int countl_one( T x ) BOOST_NOEXCEPT +{ + return boost::core::countl_zero( static_cast<T>( ~x ) ); +} + +// countr + +#if defined(__GNUC__) || defined(__clang__) + +namespace detail +{ + +BOOST_CONSTEXPR inline int countr_impl( unsigned char x ) BOOST_NOEXCEPT +{ + return x? __builtin_ctz( x ): std::numeric_limits<unsigned char>::digits; +} + +BOOST_CONSTEXPR inline int countr_impl( unsigned short x ) BOOST_NOEXCEPT +{ + return x? __builtin_ctz( x ): std::numeric_limits<unsigned short>::digits; +} + +BOOST_CONSTEXPR inline int countr_impl( unsigned int x ) BOOST_NOEXCEPT +{ + return x? __builtin_ctz( x ): std::numeric_limits<unsigned int>::digits; +} + +BOOST_CONSTEXPR inline int countr_impl( unsigned long x ) BOOST_NOEXCEPT +{ + return x? __builtin_ctzl( x ): std::numeric_limits<unsigned long>::digits; +} + +BOOST_CONSTEXPR inline int countr_impl( boost::ulong_long_type x ) BOOST_NOEXCEPT +{ + return x? __builtin_ctzll( x ): std::numeric_limits<boost::ulong_long_type>::digits; +} + +} // namespace detail + +template<class T> +BOOST_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT +{ + return boost::core::detail::countr_impl( x ); +} + +#else // defined(__GNUC__) || defined(__clang__) + +namespace detail +{ + +inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT +{ +#if defined(_MSC_VER) + + unsigned long r; + + if( _BitScanForward( &r, x ) ) + { + return static_cast<int>( r ); + } + else + { + return 32; + } + +#else + + static unsigned char const mod37[ 37 ] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 }; + return mod37[ ( -(boost::int32_t)x & x ) % 37 ]; + +#endif +} + +inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT +{ +#if defined(_MSC_VER) && defined(_M_X64) + + unsigned long r; + + if( _BitScanForward64( &r, x ) ) + { + return static_cast<int>( r ); + } + else + { + return 64; + } + +#else + + return static_cast<boost::uint32_t>( x ) != 0? + boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ): + boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32; + +#endif +} + +inline int countr_impl( boost::uint8_t x ) BOOST_NOEXCEPT +{ + return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x100 ); +} + +inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT +{ + return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x10000 ); +} + +} // namespace detail + +template<class T> +int countr_zero( T x ) BOOST_NOEXCEPT +{ + BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) ); + + if( sizeof(T) == sizeof(boost::uint8_t) ) + { + return boost::core::detail::countr_impl( static_cast<boost::uint8_t>( x ) ); + } + else if( sizeof(T) == sizeof(boost::uint16_t) ) + { + return boost::core::detail::countr_impl( static_cast<boost::uint16_t>( x ) ); + } + else if( sizeof(T) == sizeof(boost::uint32_t) ) + { + return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ); + } + else + { + return boost::core::detail::countr_impl( static_cast<boost::uint64_t>( x ) ); + } +} + +#endif // defined(__GNUC__) || defined(__clang__) + +template<class T> +BOOST_CONSTEXPR int countr_one( T x ) BOOST_NOEXCEPT +{ + return boost::core::countr_zero( static_cast<T>( ~x ) ); +} + +// popcount + +#if defined(__GNUC__) || defined(__clang__) + +#if defined(__clang__) && __clang_major__ * 100 + __clang_minor__ < 304 +# define BOOST_CORE_POPCOUNT_CONSTEXPR +#else +# define BOOST_CORE_POPCOUNT_CONSTEXPR BOOST_CONSTEXPR +#endif + +namespace detail +{ + +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned char x ) BOOST_NOEXCEPT +{ + return __builtin_popcount( x ); +} + +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned short x ) BOOST_NOEXCEPT +{ + return __builtin_popcount( x ); +} + +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned int x ) BOOST_NOEXCEPT +{ + return __builtin_popcount( x ); +} + +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long x ) BOOST_NOEXCEPT +{ + return __builtin_popcountl( x ); +} + +BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( boost::ulong_long_type x ) BOOST_NOEXCEPT +{ + return __builtin_popcountll( x ); +} + +} // namespace detail + +#undef BOOST_CORE_POPCOUNT_CONSTEXPR + +template<class T> +BOOST_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT +{ + return boost::core::detail::popcount_impl( x ); +} + +#else // defined(__GNUC__) || defined(__clang__) + +namespace detail +{ + +BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint32_t x ) BOOST_NOEXCEPT +{ + x = x - ( ( x >> 1 ) & 0x55555555 ); + x = ( x & 0x33333333 ) + ( ( x >> 2 ) & 0x33333333 ); + x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F; + + return static_cast<unsigned>( ( x * 0x01010101 ) >> 24 ); +} + +BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint64_t x ) BOOST_NOEXCEPT +{ + x = x - ( ( x >> 1 ) & 0x5555555555555555 ); + x = ( x & 0x3333333333333333 ) + ( ( x >> 2 ) & 0x3333333333333333 ); + x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F0F0F0F0F; + + return static_cast<unsigned>( ( x * 0x0101010101010101 ) >> 56 ); +} + +} // namespace detail + +template<class T> +BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT +{ + BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) ); + + if( sizeof(T) <= sizeof(boost::uint32_t) ) + { + return boost::core::detail::popcount_impl( static_cast<boost::uint32_t>( x ) ); + } + else + { + return boost::core::detail::popcount_impl( static_cast<boost::uint64_t>( x ) ); + } +} + +#endif // defined(__GNUC__) || defined(__clang__) + +// rotating + +template<class T> +BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT +{ + unsigned const mask = std::numeric_limits<T>::digits - 1; + return x << (s & mask) | x >> ((-s) & mask); +} + +template<class T> +BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT +{ + unsigned const mask = std::numeric_limits<T>::digits - 1; + return x >> (s & mask) | x << ((-s) & mask); +} + +// integral powers of 2 + +template<class T> +BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT +{ + return x != 0 && ( x & ( x - 1 ) ) == 0; +} + +// bit_width should return int, https://cplusplus.github.io/LWG/issue3656 + +template<class T> +BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT +{ + return static_cast<T>( + std::numeric_limits<T>::digits - boost::core::countl_zero( x ) ); +} + +template<class T> +BOOST_CONSTEXPR T bit_floor( T x ) BOOST_NOEXCEPT +{ + return x == 0? 0: T(1) << ( boost::core::bit_width( x ) - 1 ); +} + +namespace detail +{ + +BOOST_CXX14_CONSTEXPR inline boost::uint32_t bit_ceil_impl( boost::uint32_t x ) BOOST_NOEXCEPT +{ + if( x == 0 ) + { + return 0; + } + + --x; + + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + + ++x; + + return x; +} + +BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x ) BOOST_NOEXCEPT +{ + if( x == 0 ) + { + return 0; + } + + --x; + + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x |= x >> 32; + + ++x; + + return x; +} + +} // namespace detail + +template<class T> +BOOST_CXX14_CONSTEXPR T bit_ceil( T x ) BOOST_NOEXCEPT +{ + BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) ); + + if( sizeof(T) <= sizeof(boost::uint32_t) ) + { + return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint32_t>( x ) ) ); + } + else + { + return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint64_t>( x ) ) ); + } +} + +// endian + +#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little + +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER =big + +#elif defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER + +#elif defined(__LITTLE_ENDIAN__) + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little + +#elif defined(__BIG_ENDIAN__) + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER =big + +#elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__) + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little + +#else + +# define BOOST_CORE_BIT_NATIVE_INITIALIZER + +#endif + +#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) + +enum class endian +{ + big, + little, + native BOOST_CORE_BIT_NATIVE_INITIALIZER +}; + +typedef endian endian_type; + +#else + +namespace endian +{ + +enum type +{ + big, + little, + native BOOST_CORE_BIT_NATIVE_INITIALIZER +}; + +} // namespace endian + +typedef endian::type endian_type; + +#endif + +#undef BOOST_CORE_BIT_NATIVE_INITIALIZER + +} // namespace core +} // namespace boost + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + +#endif // #ifndef BOOST_CORE_BIT_HPP_INCLUDED diff --git a/contrib/restricted/boost/integer/README.md b/contrib/restricted/boost/integer/README.md new file mode 100644 index 00000000000..a9ef55c4f48 --- /dev/null +++ b/contrib/restricted/boost/integer/README.md @@ -0,0 +1,32 @@ +# Boost.Integer + +Boost.Integer, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides +integer type support, particularly helpful in generic programming. It provides the means to select +an integer type based upon its properties, like the number of bits or the maximum supported value, +as well as compile-time bit mask selection. There is a derivative of `std::numeric_limits` that provides +integral constant expressions for `min` and `max`... +Finally, it provides two compile-time algorithms: determining the highest power of two in a +compile-time value; and computing min and max of constant expressions. + +### Directories + +* **doc** - QuickBook documentation sources +* **include** - Interface headers of Boost.Integer +* **test** - Boost.Integer unit tests + +### More information + +* [Documentation](https://boost.org/libs/integer) +* [Report bugs](https://github.com/boostorg/integer/issues/new). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. +* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). + +### Build status + +Branch | GitHub Actions | Drone | AppVeyor | Test Matrix | Dependencies | +:-------------: | -------------- | ----- | -------- | ----------- | ------------ | +[`master`](https://github.com/boostorg/integer/tree/master) | [](https://github.com/boostorg/integer/actions?query=branch%3Amaster) | [](https://drone.cpp.al/boostorg/integer) | [](https://ci.appveyor.com/project/Lastique/integer/branch/master) | [](http://www.boost.org/development/tests/master/developer/integer.html) | [](https://pdimov.github.io/boostdep-report/master/integer.html) +[`develop`](https://github.com/boostorg/integer/tree/develop) | [](https://github.com/boostorg/integer/actions?query=branch%3Adevelop) | [](https://drone.cpp.al/boostorg/integer) | [](https://ci.appveyor.com/project/Lastique/integer/branch/develop) | [](http://www.boost.org/development/tests/develop/developer/integer.html) | [](https://pdimov.github.io/boostdep-report/develop/integer.html) + +### License + +Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). diff --git a/contrib/restricted/boost/integer/include/boost/integer.hpp b/contrib/restricted/boost/integer/include/boost/integer.hpp index 9fa00194845..ad7945ac62e 100644 --- a/contrib/restricted/boost/integer/include/boost/integer.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer.hpp @@ -2,9 +2,9 @@ // Copyright Beman Dawes and Daryle Walker 1999. Distributed under the Boost // Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -// See http://www.boost.org/libs/integer for documentation. +// See https://www.boost.org/libs/integer for documentation. // Revision History // 22 Sep 01 Added value-based integer templates. (Daryle Walker) @@ -137,7 +137,7 @@ namespace boost { BOOST_STATIC_ASSERT_MSG(Bits <= (int)(sizeof(boost::uintmax_t) * CHAR_BIT), "No suitable unsigned integer type with the requested number of bits is available."); -#if (defined(__BORLANDC__) || defined(__CODEGEAR__)) && defined(BOOST_NO_INTEGRAL_INT64_T) +#if (defined(BOOST_BORLANDC) || defined(__CODEGEAR__)) && defined(BOOST_NO_INTEGRAL_INT64_T) // It's really not clear why this workaround should be needed... shrug I guess! JM BOOST_STATIC_CONSTANT(int, s = 6 + @@ -219,7 +219,7 @@ namespace boost #endif struct uint_value_t { -#if (defined(__BORLANDC__) || defined(__CODEGEAR__)) +#if (defined(BOOST_BORLANDC) || defined(__CODEGEAR__)) // It's really not clear why this workaround should be needed... shrug I guess! JM #if defined(BOOST_NO_INTEGRAL_INT64_T) BOOST_STATIC_CONSTANT(unsigned, which = diff --git a/contrib/restricted/boost/integer/include/boost/integer/common_factor_ct.hpp b/contrib/restricted/boost/integer/include/boost/integer/common_factor_ct.hpp index 0671d161c37..5769fa2d2f3 100644 --- a/contrib/restricted/boost/integer/include/boost/integer/common_factor_ct.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer/common_factor_ct.hpp @@ -3,9 +3,9 @@ // (C) Copyright Daryle Walker and Stephen Cleary 2001-2002. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt) -// See http://www.boost.org for updates, documentation, and revision history. +// See https://www.boost.org for updates, documentation, and revision history. #ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP #define BOOST_INTEGER_COMMON_FACTOR_CT_HPP @@ -30,7 +30,7 @@ namespace detail BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 ); BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 ); - #ifndef __BORLANDC__ + #ifndef BOOST_BORLANDC #define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value) #else typedef static_gcd_helper_t self_type; diff --git a/contrib/restricted/boost/integer/include/boost/integer/common_factor_rt.hpp b/contrib/restricted/boost/integer/include/boost/integer/common_factor_rt.hpp index 341b316501c..b8339c7dbb2 100644 --- a/contrib/restricted/boost/integer/include/boost/integer/common_factor_rt.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer/common_factor_rt.hpp @@ -2,7 +2,7 @@ // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP #define BOOST_INTEGER_COMMON_FACTOR_RT_HPP @@ -83,9 +83,9 @@ namespace boost { } #endif - template <class T, bool a = + template <class T, bool a = #ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS - std::is_unsigned<T>::value || + std::is_unsigned<T>::value || #endif (std::numeric_limits<T>::is_specialized && !std::numeric_limits<T>::is_signed)> struct gcd_traits_abs_defaults @@ -129,7 +129,7 @@ namespace boost { BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(T& val) BOOST_GCD_NOEXCEPT(T) { unsigned r = 0; - while(0 == (val & 1u)) + while (T(0) == (val & 1u)) { #ifdef _MSC_VER // VC++ can't handle operator >>= in constexpr code for some reason val = val >> 1; @@ -210,28 +210,28 @@ namespace boost { // this works for signed types too, as by the time these functions // are called, all values are > 0. // - template <> struct gcd_traits<long> : public gcd_traits_defaults<long> + template <> struct gcd_traits<long> : public gcd_traits_defaults<long> { BOOST_FORCEINLINE static unsigned make_odd(long& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<unsigned int> : public gcd_traits_defaults<unsigned int> + template <> struct gcd_traits<unsigned int> : public gcd_traits_defaults<unsigned int> { BOOST_FORCEINLINE static unsigned make_odd(unsigned int& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<int> : public gcd_traits_defaults<int> + template <> struct gcd_traits<int> : public gcd_traits_defaults<int> { BOOST_FORCEINLINE static unsigned make_odd(int& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short> + template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short> { BOOST_FORCEINLINE static unsigned make_odd(unsigned short& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<short> : public gcd_traits_defaults<short> + template <> struct gcd_traits<short> : public gcd_traits_defaults<short> { BOOST_FORCEINLINE static unsigned make_odd(short& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char> + template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char> { BOOST_FORCEINLINE static unsigned make_odd(unsigned char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char> - { BOOST_FORCEINLINE static signed make_odd(signed char& val)BOOST_NOEXCEPT{ signed result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; - template <> struct gcd_traits<char> : public gcd_traits_defaults<char> + template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char> + { BOOST_FORCEINLINE static unsigned make_odd(signed char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; + template <> struct gcd_traits<char> : public gcd_traits_defaults<char> { BOOST_FORCEINLINE static unsigned make_odd(char& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; #ifndef BOOST_NO_INTRINSIC_WCHAR_T - template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t> + template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t> { BOOST_FORCEINLINE static unsigned make_odd(wchar_t& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } }; #endif #ifdef _M_X64 - template <> struct gcd_traits<__int64> : public gcd_traits_defaults<__int64> + template <> struct gcd_traits<__int64> : public gcd_traits_defaults<__int64> { BOOST_FORCEINLINE static unsigned make_odd(__int64& val)BOOST_NOEXCEPT{ unsigned result = gcd_traits<unsigned __int64>::find_lsb(val); val >>= result; return result; } }; #endif @@ -310,7 +310,7 @@ namespace boost { }; template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char> { - BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR signed make_odd(signed char& val)BOOST_NOEXCEPT { signed result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; } + BOOST_FORCEINLINE static BOOST_CXX14_CONSTEXPR unsigned make_odd(signed char& val)BOOST_NOEXCEPT { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; } }; template <> struct gcd_traits<char> : public gcd_traits_defaults<char> { @@ -360,7 +360,7 @@ namespace boost { } /** Stein gcd (aka 'binary gcd') - * + * * From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose */ template <typename SteinDomain> @@ -373,8 +373,8 @@ namespace boost { if (n == SteinDomain(0)) return m; // m > 0 && n > 0 - int d_m = gcd_traits<SteinDomain>::make_odd(m); - int d_n = gcd_traits<SteinDomain>::make_odd(n); + unsigned d_m = gcd_traits<SteinDomain>::make_odd(m); + unsigned d_n = gcd_traits<SteinDomain>::make_odd(n); // odd(m) && odd(n) while (m != n) { @@ -388,11 +388,11 @@ namespace boost { return m; } - + /** Euclidean algorithm - * + * * From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose - * + * */ template <typename EuclideanDomain> inline BOOST_CXX14_CONSTEXPR EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b) BOOST_GCD_NOEXCEPT(EuclideanDomain) @@ -494,10 +494,10 @@ inline typename boost::enable_if_c<std::numeric_limits<Integer>::is_specialized, * * Knuth counts down from n to zero but we naturally go from first to last. * We also return the termination position because it might be useful to know. - * - * Partly by quirk, partly by design, this algorithm is defined for n = 1, + * + * Partly by quirk, partly by design, this algorithm is defined for n = 1, * because the gcd of {x} is x. It is not defined for n = 0. - * + * * @tparam I Input iterator. * @return The gcd of the range and the iterator position at termination. */ @@ -507,12 +507,13 @@ gcd_range(I first, I last) BOOST_GCD_NOEXCEPT(I) { BOOST_ASSERT(first != last); typedef typename std::iterator_traits<I>::value_type T; - - T d = *first++; + + T d = *first; + ++first; while (d != T(1) && first != last) { d = gcd(d, *first); - first++; + ++first; } return std::make_pair(d, first); } @@ -522,12 +523,13 @@ lcm_range(I first, I last) BOOST_GCD_NOEXCEPT(I) { BOOST_ASSERT(first != last); typedef typename std::iterator_traits<I>::value_type T; - - T d = *first++; - while (d != T(1) && first != last) + + T d = *first; + ++first; + while (d != T(0) && first != last) { d = lcm(d, *first); - first++; + ++first; } return std::make_pair(d, first); } @@ -544,7 +546,7 @@ public: typedef IntegerType second_argument_type; typedef IntegerType result_type; #endif - IntegerType operator()(IntegerType const &a, IntegerType const &b)const + IntegerType operator()(IntegerType const &a, IntegerType const &b) const { return boost::integer::gcd(a, b); } diff --git a/contrib/restricted/boost/integer/include/boost/integer/integer_log2.hpp b/contrib/restricted/boost/integer/include/boost/integer/integer_log2.hpp index 8b34ce7440a..8ca236f6189 100644 --- a/contrib/restricted/boost/integer/include/boost/integer/integer_log2.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer/integer_log2.hpp @@ -4,109 +4,114 @@ // Gives the integer part of the logarithm, in base 2, of a // given number. Behavior is undefined if the argument is <= 0. // -// Copyright (c) 2003-2004, 2008 Gennaro Prota +// Copyright (c) 2003-2004, 2008 Gennaro Prota +// Copyright (c) 2022 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt) // // ----------------------------------------------------------- #ifndef BOOST_INTEGER_INTEGER_LOG2_HPP #define BOOST_INTEGER_INTEGER_LOG2_HPP -#include <assert.h> -#ifdef __BORLANDC__ #include <climits> -#endif -#include <boost/limits.hpp> +#include <limits> #include <boost/config.hpp> - +#include <boost/assert.hpp> +#include <boost/cstdint.hpp> +#include <boost/core/bit.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/make_unsigned.hpp> namespace boost { - namespace detail { - - template <typename T> - int integer_log2_impl(T x, int n) { - - int result = 0; - - while (x != 1) { - - const T t = static_cast<T>(x >> n); - if (t) { - result += n; - x = t; - } - n /= 2; - - } - - return result; - } - - - - // helper to find the maximum power of two - // less than p (more involved than necessary, - // to avoid PTS) - // - template <int p, int n> - struct max_pow2_less { - - enum { c = 2*n < p }; - - BOOST_STATIC_CONSTANT(int, value = - c ? (max_pow2_less< c*p, 2*c*n>::value) : n); - - }; - - template <> - struct max_pow2_less<0, 0> { - - BOOST_STATIC_CONSTANT(int, value = 0); - }; - - // this template is here just for Borland :( - // we could simply rely on numeric_limits but sometimes - // Borland tries to use numeric_limits<const T>, because - // of its usual const-related problems in argument deduction - // - gps - template <typename T> - struct width { - -#ifdef __BORLANDC__ - BOOST_STATIC_CONSTANT(int, value = sizeof(T) * CHAR_BIT); +namespace detail { + +// helper to find the maximum power of two +// less than p +template< unsigned int p, unsigned int n, bool = ((2u * n) < p) > +struct max_pow2_less : + public max_pow2_less< p, 2u * n > +{ +}; + +template< unsigned int p, unsigned int n > +struct max_pow2_less< p, n, false > +{ + BOOST_STATIC_CONSTANT(unsigned int, value = n); +}; + +template< typename T > +inline typename boost::disable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x) +{ + unsigned int n = detail::max_pow2_less< + std::numeric_limits< T >::digits, + CHAR_BIT / 2u + >::value; + + int result = 0; + while (x != 1) + { + T t(x >> n); + if (t) + { + result += static_cast< int >(n); +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + x = static_cast< T&& >(t); #else - BOOST_STATIC_CONSTANT(int, value = (std::numeric_limits<T>::digits)); + x = t; #endif + } + n >>= 1u; + } - }; - - } // detail - - - // --------- - // integer_log2 - // --------------- - // - template <typename T> - int integer_log2(T x) { - - assert(x > 0); + return result; +} - const int n = detail::max_pow2_less< - detail::width<T> :: value, 4 - > :: value; +template< typename T > +inline typename boost::enable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x) +{ + // We could simply rely on numeric_limits but sometimes + // Borland tries to use numeric_limits<const T>, because + // of its usual const-related problems in argument deduction + // - gps + return static_cast< int >((sizeof(T) * CHAR_BIT - 1u) - + boost::core::countl_zero(static_cast< typename boost::make_unsigned< T >::type >(x))); +} - return detail::integer_log2_impl(x, n); +#if defined(BOOST_HAS_INT128) +// We need to provide explicit overloads for __int128 because (a) boost/core/bit.hpp currently does not support it and +// (b) std::numeric_limits are not specialized for __int128 in some standard libraries. +inline int integer_log2_impl(boost::uint128_type x) +{ + const boost::uint64_t x_hi = static_cast< boost::uint64_t >(x >> 64u); + if (x_hi != 0u) + return 127 - boost::core::countl_zero(x_hi); + else + return 63 - boost::core::countl_zero(static_cast< boost::uint64_t >(x)); +} - } +inline int integer_log2_impl(boost::int128_type x) +{ + return detail::integer_log2_impl(static_cast< boost::uint128_type >(x)); +} +#endif // defined(BOOST_HAS_INT128) +} // namespace detail +// ------------ +// integer_log2 +// ------------ +template< typename T > +inline int integer_log2(T x) +{ + BOOST_ASSERT(x > 0); + return detail::integer_log2_impl(x); } +} // namespace boost - -#endif // include guard +#endif // BOOST_INTEGER_INTEGER_LOG2_HPP diff --git a/contrib/restricted/boost/integer/include/boost/integer/integer_mask.hpp b/contrib/restricted/boost/integer/include/boost/integer/integer_mask.hpp index eee4679b84b..3be5035b82c 100644 --- a/contrib/restricted/boost/integer/include/boost/integer/integer_mask.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer/integer_mask.hpp @@ -3,9 +3,9 @@ // (C) Copyright Daryle Walker 2001. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt) -// See http://www.boost.org for updates, documentation, and revision history. +// See https://www.boost.org for updates, documentation, and revision history. #ifndef BOOST_INTEGER_INTEGER_MASK_HPP #define BOOST_INTEGER_INTEGER_MASK_HPP diff --git a/contrib/restricted/boost/integer/include/boost/integer/static_log2.hpp b/contrib/restricted/boost/integer/include/boost/integer/static_log2.hpp index 56c7a001251..325ea2c117a 100644 --- a/contrib/restricted/boost/integer/include/boost/integer/static_log2.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer/static_log2.hpp @@ -6,17 +6,18 @@ // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt) // // --------------------------------------------------- -// See http://www.boost.org/libs/integer for documentation. +// See https://www.boost.org/libs/integer for documentation. // ------------------------------------------------------------------------- // #ifndef BOOST_INTEGER_STATIC_LOG2_HPP #define BOOST_INTEGER_STATIC_LOG2_HPP -#include "boost/integer_fwd.hpp" // for boost::intmax_t +#include <boost/config.hpp> +#include <boost/integer_fwd.hpp> namespace boost { @@ -122,6 +123,4 @@ namespace boost { } - - #endif // include guard diff --git a/contrib/restricted/boost/integer/include/boost/integer/static_min_max.hpp b/contrib/restricted/boost/integer/include/boost/integer/static_min_max.hpp index ee76fd424a1..bfe1e260c52 100644 --- a/contrib/restricted/boost/integer/include/boost/integer/static_min_max.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer/static_min_max.hpp @@ -3,13 +3,14 @@ // (C) Copyright Daryle Walker 2001. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt) -// See http://www.boost.org for updates, documentation, and revision history. +// See https://www.boost.org for updates, documentation, and revision history. #ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP #define BOOST_INTEGER_STATIC_MIN_MAX_HPP +#include <boost/config.hpp> #include <boost/integer_fwd.hpp> // self include namespace boost diff --git a/contrib/restricted/boost/integer/include/boost/integer_fwd.hpp b/contrib/restricted/boost/integer/include/boost/integer_fwd.hpp index 18519dd696d..6eac5aafb4d 100644 --- a/contrib/restricted/boost/integer/include/boost/integer_fwd.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer_fwd.hpp @@ -2,9 +2,9 @@ // (C) Copyright Dave Abrahams and Daryle Walker 2001. Distributed under the Boost // Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -// See http://www.boost.org/libs/integer for documentation. +// See https://www.boost.org/libs/integer for documentation. #ifndef BOOST_INTEGER_FWD_HPP #define BOOST_INTEGER_FWD_HPP diff --git a/contrib/restricted/boost/integer/include/boost/integer_traits.hpp b/contrib/restricted/boost/integer/include/boost/integer_traits.hpp index 94eb00d31e4..c2d4897a65a 100644 --- a/contrib/restricted/boost/integer/include/boost/integer_traits.hpp +++ b/contrib/restricted/boost/integer/include/boost/integer_traits.hpp @@ -3,14 +3,14 @@ * Copyright Jens Maurer 2000 * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) + * https://www.boost.org/LICENSE_1_0.txt) * * $Id$ * * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers */ -// See http://www.boost.org/libs/integer for documentation. +// See https://www.boost.org/libs/integer for documentation. #ifndef BOOST_INTEGER_TRAITS_HPP @@ -103,7 +103,7 @@ class integer_traits<wchar_t> // library: they are wrong! #if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__) public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX> -#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__)) +#elif defined(BOOST_BORLANDC) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__)) // No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned: public detail::integer_traits_base<wchar_t, 0, 0xffff> #elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\ diff --git a/contrib/restricted/boost/integer/include/boost/pending/integer_log2.hpp b/contrib/restricted/boost/integer/include/boost/pending/integer_log2.hpp index 023ec7af038..938459463d8 100644 --- a/contrib/restricted/boost/integer/include/boost/pending/integer_log2.hpp +++ b/contrib/restricted/boost/integer/include/boost/pending/integer_log2.hpp @@ -1,9 +1,9 @@ #ifndef BOOST_PENDING_INTEGER_LOG2_HPP #define BOOST_PENDING_INTEGER_LOG2_HPP -// The header file at this path is deprecated; -// use boost/integer/integer_log2.hpp instead. - #include <boost/integer/integer_log2.hpp> +#include <boost/config/header_deprecated.hpp> + +BOOST_HEADER_DEPRECATED("<boost/integer/integer_log2.hpp>"); #endif |