Improve bx::saturateCast. (#357)

This commit is contained in:
Branimir Karadžić
2025-12-13 22:06:56 -08:00
committed by GitHub
parent a9f99c627e
commit a69b0a72f7
2 changed files with 3 additions and 3 deletions

View File

@@ -227,7 +227,7 @@ namespace bx
/// Performs `static_cast` of value `_from`, and if value doesn't fit result type `Ty` it clamps
/// the value to `Ty` min/max.
template<typename Ty, typename FromT>
constexpr Ty saturateCast(const FromT& _from);
constexpr Ty saturateCast(FromT _from);
/// Performs `static_cast` of value `_from`, and returns true if the value `_from` is
/// representable as `Ty`.

View File

@@ -174,9 +174,9 @@ namespace bx
template<typename Ty, typename FromT>
requires (isInteger< Ty>() || isFloatingPoint< Ty>() )
&& (isInteger<FromT>() || isFloatingPoint<FromT>() )
inline constexpr Ty saturateCast(const FromT& _from)
inline constexpr Ty saturateCast(FromT _from)
{
if constexpr (isSame<Ty, FromT>() )
if constexpr (isSame<RemoveCvType<Ty>, RemoveCvType<FromT> >() )
{
return _from;
}