diff options
author | Krzysztof Kosiński <krzysio@google.com> | 2024-01-12 22:08:39 +0000 |
---|---|---|
committer | Krzysztof Kosiński <krzysio@google.com> | 2024-01-12 22:16:56 +0000 |
commit | 6f56677b3f8b18c6e63c5779bf3dceea75685c12 (patch) | |
tree | fb22bbbde0c615b678d2d293a510e985be516a0f /abseil-cpp/absl/random/internal/fast_uniform_bits.h | |
parent | 2d1fbf685c945f8513d1dece20f3a967d766134b (diff) | |
download | libtextclassifier-6f56677b3f8b18c6e63c5779bf3dceea75685c12.tar.gz |
Upgrade the guerrilla import of ABSL.
Accomplished by deleting everything other than Android.bp,
copying and pasting all files from external/abseil-cpp, then
removing the unnecessary package-level files.
Bug: 246681282
Test: mm, presubmit
Change-Id: Id227c437995a7b867748f4d1d680293cb0038487
Diffstat (limited to 'abseil-cpp/absl/random/internal/fast_uniform_bits.h')
-rw-r--r-- | abseil-cpp/absl/random/internal/fast_uniform_bits.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/abseil-cpp/absl/random/internal/fast_uniform_bits.h b/abseil-cpp/absl/random/internal/fast_uniform_bits.h index 425aaf7..83ee5c0 100644 --- a/abseil-cpp/absl/random/internal/fast_uniform_bits.h +++ b/abseil-cpp/absl/random/internal/fast_uniform_bits.h @@ -22,6 +22,7 @@ #include "absl/base/config.h" #include "absl/meta/type_traits.h" +#include "absl/random/internal/traits.h" namespace absl { ABSL_NAMESPACE_BEGIN @@ -56,9 +57,10 @@ constexpr UIntType IntegerLog2(UIntType n) { // `PowerOfTwoVariate(urbg)`. template <typename URBG> constexpr size_t NumBits() { - return RangeSize<URBG>() == 0 - ? std::numeric_limits<typename URBG::result_type>::digits - : IntegerLog2(RangeSize<URBG>()); + return static_cast<size_t>( + RangeSize<URBG>() == 0 + ? std::numeric_limits<typename URBG::result_type>::digits + : IntegerLog2(RangeSize<URBG>())); } // Given a shift value `n`, constructs a mask with exactly the low `n` bits set. @@ -98,7 +100,7 @@ class FastUniformBits { result_type operator()(URBG& g); // NOLINT(runtime/references) private: - static_assert(std::is_unsigned<UIntType>::value, + static_assert(IsUnsigned<UIntType>::value, "Class-template FastUniformBits<> must be parameterized using " "an unsigned type."); @@ -150,7 +152,8 @@ FastUniformBits<UIntType>::Generate(URBG& g, // NOLINT(runtime/references) result_type r = static_cast<result_type>(g() - kMin); for (size_t n = 1; n < kIters; ++n) { - r = (r << kShift) + static_cast<result_type>(g() - kMin); + r = static_cast<result_type>(r << kShift) + + static_cast<result_type>(g() - kMin); } return r; } |