diff options
author | Benjamin Barenblat <bbaren@google.com> | 2024-05-08 10:59:21 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2024-05-08 10:59:21 -0400 |
commit | d8e2b896d5e3c1ebf2d6d0d37bd9e7a1b59e0b99 (patch) | |
tree | 33d0793fcdd3615f21e5b4f0e50ae20811a5bde5 /absl/numeric/bits.h | |
parent | 57fc09f12cfb9642e7ebd4ca3c64d07154d2de9a (diff) | |
parent | d7aaad83b488fd62bd51c81ecf16cd938532cc0a (diff) | |
download | abseil-d8e2b896d5e3c1ebf2d6d0d37bd9e7a1b59e0b99.tar.gz abseil-d8e2b896d5e3c1ebf2d6d0d37bd9e7a1b59e0b99.tar.bz2 abseil-d8e2b896d5e3c1ebf2d6d0d37bd9e7a1b59e0b99.zip |
Merge new upstream LTS 20240116.2
Diffstat (limited to 'absl/numeric/bits.h')
-rw-r--r-- | absl/numeric/bits.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/absl/numeric/bits.h b/absl/numeric/bits.h index 5ed36f52..c76454c8 100644 --- a/absl/numeric/bits.h +++ b/absl/numeric/bits.h @@ -49,9 +49,19 @@ namespace absl { ABSL_NAMESPACE_BEGIN -#if !(defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L) -// rotating +// https://github.com/llvm/llvm-project/issues/64544 +// libc++ had the wrong signature for std::rotl and std::rotr +// prior to libc++ 18.0. +// +#if (defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L) && \ + (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 180000) +using std::rotl; +using std::rotr; + +#else + +// Rotating functions template <class T> ABSL_MUST_USE_RESULT constexpr typename std::enable_if<std::is_unsigned<T>::value, T>::type @@ -66,6 +76,22 @@ ABSL_MUST_USE_RESULT constexpr return numeric_internal::RotateRight(x, s); } +#endif + +// https://github.com/llvm/llvm-project/issues/64544 +// libc++ had the wrong signature for std::rotl and std::rotr +// prior to libc++ 18.0. +// +#if (defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L) + +using std::countl_one; +using std::countl_zero; +using std::countr_one; +using std::countr_zero; +using std::popcount; + +#else + // Counting functions // // While these functions are typically constexpr, on some platforms, they may @@ -107,19 +133,18 @@ ABSL_INTERNAL_CONSTEXPR_POPCOUNT inline popcount(T x) noexcept { return numeric_internal::Popcount(x); } -#else // defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L - -using std::countl_one; -using std::countl_zero; -using std::countr_one; -using std::countr_zero; -using std::popcount; -using std::rotl; -using std::rotr; #endif -#if !(defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L) +#if (defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L) + +using std::bit_ceil; +using std::bit_floor; +using std::bit_width; +using std::has_single_bit; + +#else + // Returns: true if x is an integral power of two; false otherwise. template <class T> constexpr inline typename std::enable_if<std::is_unsigned<T>::value, bool>::type @@ -162,12 +187,6 @@ ABSL_INTERNAL_CONSTEXPR_CLZ inline return has_single_bit(x) ? T{1} << (bit_width(x) - 1) : numeric_internal::BitCeilNonPowerOf2(x); } -#else // defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L - -using std::bit_ceil; -using std::bit_floor; -using std::bit_width; -using std::has_single_bit; #endif |