diff options
author | Abseil Team <absl-team@google.com> | 2022-08-18 10:44:22 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-08-18 10:45:18 -0700 |
commit | 188138facb785e704e2107a3fee58cf9672a22cc (patch) | |
tree | 4b4090e543bf65cdae317fd3902cc6164a3dd4f7 /absl/numeric | |
parent | d06b89b25d642ac26171571dbaf9a97e3da70ce4 (diff) |
Change bit_width(T) to return int rather than T.
This matches std::bit_width().
Bug: chromium:1292951
PiperOrigin-RevId: 468495319
Change-Id: I0e428addb6a7353abbf2063c5c2f5820c3bae789
Diffstat (limited to 'absl/numeric')
-rw-r--r-- | absl/numeric/bits.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/absl/numeric/bits.h b/absl/numeric/bits.h index 628cdf50..df81b9a9 100644 --- a/absl/numeric/bits.h +++ b/absl/numeric/bits.h @@ -131,10 +131,9 @@ has_single_bit(T x) noexcept { // fractional part discarded. template <class T> ABSL_INTERNAL_CONSTEXPR_CLZ inline - typename std::enable_if<std::is_unsigned<T>::value, T>::type + typename std::enable_if<std::is_unsigned<T>::value, int>::type bit_width(T x) noexcept { - return std::numeric_limits<T>::digits - - static_cast<unsigned int>(countl_zero(x)); + return std::numeric_limits<T>::digits - countl_zero(x); } // Returns: If x == 0, 0; otherwise the maximal value y such that |