From bae7c049b0ae8bc0004d1c32966107432e13fa73 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 19 Jan 2022 17:20:39 +0200 Subject: [PATCH] Avoid conversion warning in bit_width --- include/boost/core/bit.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/core/bit.hpp b/include/boost/core/bit.hpp index f4305b9..7efb7c7 100644 --- a/include/boost/core/bit.hpp +++ b/include/boost/core/bit.hpp @@ -446,10 +446,13 @@ BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT return x != 0 && ( x & ( x - 1 ) ) == 0; } +// bit_width should return int, https://cplusplus.github.io/LWG/issue3656 + template BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT { - return std::numeric_limits::digits - boost::core::countl_zero( x ); + return static_cast( + std::numeric_limits::digits - boost::core::countl_zero( x ) ); } template