|
|
|
@ -399,10 +399,9 @@ template<std::size_t size, class T> inline Vector<size, T> clamp(const Vector<si |
|
|
|
|
|
|
|
|
|
|
|
Returns `1` if @p x > 0, `0` if @p x = 0 and `-1` if @p x < 0. |
|
|
|
Returns `1` if @p x > 0, `0` if @p x = 0 and `-1` if @p x < 0. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
template<class T> inline typename std::enable_if<IsScalar<T>::value, UnderlyingTypeOf<T>>::type sign(T scalar) { |
|
|
|
template<class T> constexpr inline typename std::enable_if<IsScalar<T>::value, UnderlyingTypeOf<T>>::type sign(T x) { |
|
|
|
if(scalar > T(0)) return UnderlyingTypeOf<T>(1); |
|
|
|
using U = UnderlyingTypeOf<T>; |
|
|
|
if(scalar < T(0)) return UnderlyingTypeOf<T>(-1); |
|
|
|
return U(U(bool(x > T(0))) - U(bool(x < T(0)))); |
|
|
|
return UnderlyingTypeOf<T>(0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** @overload */ |
|
|
|
/** @overload */ |
|
|
|
|