Fix compiler warnings

This commit is contained in:
John Wellbelove 2021-10-27 09:47:52 +01:00
parent e6dd894896
commit 36bb393d7a
3 changed files with 13 additions and 11 deletions

View File

@ -870,7 +870,7 @@ namespace etl
count = ((count >> 4U) + count) & 0x0F0FU;
count = ((count >> 8U) + count) & 0x00FFU;
return count;
return static_cast<uint_least8_t>(count);
}
inline ETL_CONSTEXPR14 uint_least8_t count_bits(int16_t value)
@ -892,7 +892,7 @@ namespace etl
count = ((count >> 8U) + count) & 0x00FF00FFUL;
count = ((count >> 16U) + count) & 0x0000FFUL;
return uint_least8_t(count);
return static_cast<uint_least8_t>(count);;
}
inline ETL_CONSTEXPR14 uint_least8_t count_bits(int32_t value)
@ -916,7 +916,7 @@ namespace etl
count = ((count >> 16U) + count) & 0x0000FFFF0000FFFFULL;
count = ((count >> 32U) + count) & 0x00000000FFFFFFFFULL;
return uint_least8_t(count);
return static_cast<uint_least8_t>(count);
}
inline ETL_CONSTEXPR14 uint_least8_t count_bits(int64_t value)

View File

@ -237,7 +237,7 @@ namespace etl
size_t operator ()(long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
@ -259,7 +259,7 @@ namespace etl
size_t operator ()(long long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
@ -281,7 +281,7 @@ namespace etl
size_t operator ()(unsigned long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
@ -303,7 +303,7 @@ namespace etl
size_t operator ()(unsigned long long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
@ -325,7 +325,7 @@ namespace etl
size_t operator ()(float v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) == sizeof(v))
{
union
{
@ -355,7 +355,7 @@ namespace etl
size_t operator ()(double v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) == sizeof(v))
{
union
{
@ -385,7 +385,7 @@ namespace etl
size_t operator ()(long double v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(v))
if ETL_IF_CONSTEXPR(sizeof(size_t) == sizeof(v))
{
union
{

View File

@ -92,14 +92,16 @@ namespace etl
//***************************************************************************
///\ingroup integral_limits
//***************************************************************************
#pragma warning( disable : 4309 )
template <>
struct integral_limits<char>
{
static ETL_CONSTANT char min = (etl::is_signed<char>::value) ? SCHAR_MIN : 0;
static ETL_CONSTANT char max = (etl::is_signed<char>::value) ? SCHAR_MAX : char(UCHAR_MAX);
static ETL_CONSTANT char max = (etl::is_signed<char>::value) ? SCHAR_MAX : static_cast<char>(UCHAR_MAX);
static ETL_CONSTANT int bits = CHAR_BIT;
static ETL_CONSTANT bool is_signed = etl::is_signed<char>::value;
};
#pragma warning( default : 4309 )
//***************************************************************************
///\ingroup integral_limits