summaryrefslogtreecommitdiff
path: root/absl/numeric/bits.h
diff options
context:
space:
mode:
authorGravatar Thomas Köppe <tkoeppe@google.com>2022-08-04 06:14:14 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-08-04 06:15:05 -0700
commit4b551344e6ba3243636d841d5a2d944a20a3a956 (patch)
tree95f8c347117f509f5aa9fab0b05f3c55d1ce73cf /absl/numeric/bits.h
parent751ade00ee347abef5dac7248db851e3f2012e14 (diff)
Revert change "Fix "unsafe narrowing" warnings in absl, 4/n.".
The change breaks existing code by changing the return type of absl::bit_width. PiperOrigin-RevId: 465295951 Change-Id: Id4ce7c2ac3699ce22aa2b4851a949f9e0104a3d7
Diffstat (limited to 'absl/numeric/bits.h')
-rw-r--r--absl/numeric/bits.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/absl/numeric/bits.h b/absl/numeric/bits.h
index df81b9a9..628cdf50 100644
--- a/absl/numeric/bits.h
+++ b/absl/numeric/bits.h
@@ -131,9 +131,10 @@ 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, int>::type
+ typename std::enable_if<std::is_unsigned<T>::value, T>::type
bit_width(T x) noexcept {
- return std::numeric_limits<T>::digits - countl_zero(x);
+ return std::numeric_limits<T>::digits -
+ static_cast<unsigned int>(countl_zero(x));
}
// Returns: If x == 0, 0; otherwise the maximal value y such that