Explorar o código

Improve bx::saturateCast. (#357)

Branimir Karadžić hai 1 mes
pai
achega
a69b0a72f7
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 1 1
      include/bx/bx.h
  2. 2 2
      include/bx/inline/bx.inl

+ 1 - 1
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<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`.

+ 2 - 2
include/bx/inline/bx.inl

@@ -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;
 		}