From a69b0a72f7edc386211e58ba6a3d20d4046bcfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 13 Dec 2025 22:06:56 -0800 Subject: [PATCH] Improve bx::saturateCast. (#357) --- include/bx/bx.h | 2 +- include/bx/inline/bx.inl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/bx/bx.h b/include/bx/bx.h index 9706862..a45057d 100644 --- a/include/bx/bx.h +++ b/include/bx/bx.h @@ -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 - 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`. diff --git a/include/bx/inline/bx.inl b/include/bx/inline/bx.inl index ab20841..1bd971c 100644 --- a/include/bx/inline/bx.inl +++ b/include/bx/inline/bx.inl @@ -174,9 +174,9 @@ namespace bx template requires (isInteger< Ty>() || isFloatingPoint< Ty>() ) && (isInteger() || isFloatingPoint() ) - inline constexpr Ty saturateCast(const FromT& _from) + inline constexpr Ty saturateCast(FromT _from) { - if constexpr (isSame() ) + if constexpr (isSame, RemoveCvType >() ) { return _from; }