Fix: Use static_cast instead of C-cast to avoid hidden errors.

This commit is contained in:
Peter Nelson 2024-04-08 17:07:56 +01:00 committed by Peter Nelson
parent cdfffb551c
commit 4daf95b878
1 changed files with 5 additions and 5 deletions

View File

@ -22,7 +22,7 @@
template <typename T>
constexpr T abs(const T a)
{
return (a < (T)0) ? -a : a;
return (a < static_cast<T>(0)) ? -a : a;
}
/**
@ -38,7 +38,7 @@ constexpr T Align(const T x, uint n)
{
assert((n & (n - 1)) == 0 && n != 0);
n--;
return (T)((x + n) & ~((T)n));
return static_cast<T>((x + n) & ~static_cast<T>(n));
}
/**
@ -251,7 +251,7 @@ constexpr T Delta(const T a, const T b)
template <typename T>
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
{
return (size_t)(x - base) < size;
return static_cast<size_t>(x - base) < size;
}
/**
@ -268,9 +268,9 @@ template <typename T, std::enable_if_t<std::disjunction_v<std::is_convertible<T,
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
{
if constexpr (std::is_base_of_v<StrongTypedefBase, T>) {
return (size_t)(x.base() - min) < (max - min);
return static_cast<size_t>(x.base() - min) < (max - min);
} else {
return (size_t)(x - min) < (max - min);
return static_cast<size_t>(x - min) < (max - min);
}
}