From 188138facb785e704e2107a3fee58cf9672a22cc Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 18 Aug 2022 10:44:22 -0700 Subject: [PATCH] Change bit_width(T) to return int rather than T. This matches std::bit_width(). Bug: chromium:1292951 PiperOrigin-RevId: 468495319 Change-Id: I0e428addb6a7353abbf2063c5c2f5820c3bae789 --- absl/numeric/bits.h | 5 ++--- 1 file 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 ABSL_INTERNAL_CONSTEXPR_CLZ inline - typename std::enable_if::value, T>::type + typename std::enable_if::value, int>::type bit_width(T x) noexcept { - return std::numeric_limits::digits - - static_cast(countl_zero(x)); + return std::numeric_limits::digits - countl_zero(x); } // Returns: If x == 0, 0; otherwise the maximal value y such that