mirror of
https://github.com/boostorg/core.git
synced 2025-07-30 21:07:22 +02:00
Avoid conversion warning in bit_width
This commit is contained in:
@ -446,10 +446,13 @@ BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
|
|||||||
return x != 0 && ( x & ( x - 1 ) ) == 0;
|
return x != 0 && ( x & ( x - 1 ) ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bit_width should return int, https://cplusplus.github.io/LWG/issue3656
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
|
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return std::numeric_limits<T>::digits - boost::core::countl_zero( x );
|
return static_cast<T>(
|
||||||
|
std::numeric_limits<T>::digits - boost::core::countl_zero( x ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
Reference in New Issue
Block a user