bx::saturateCast requries values to be integer or float. (#356)

This commit is contained in:
Branimir Karadžić
2025-12-13 20:02:08 -08:00
committed by GitHub
parent f4a30a69a1
commit a9f99c627e

View File

@@ -172,6 +172,8 @@ namespace bx
} }
template<typename Ty, typename FromT> 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(const FromT& _from)
{ {
if constexpr (isSame<Ty, FromT>() ) if constexpr (isSame<Ty, FromT>() )
@@ -225,7 +227,7 @@ namespace bx
return true; return true;
} }
*_out = saturateCast<Ty>(_from); *_out = static_cast<Ty>(_from);
return static_cast<FromT>(*_out) == _from; return static_cast<FromT>(*_out) == _from;
} }