Browse Source

Merge 4ed3ad59e9 into 820382767c

pull/651/merge
Stanislaw Halik 1 year ago committed by GitHub
parent
commit
9367781090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      src/Magnum/Math/Functions.h

7
src/Magnum/Math/Functions.h

@ -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.
*/
template<class T> inline typename std::enable_if<IsScalar<T>::value, UnderlyingTypeOf<T>>::type sign(T scalar) {
if(scalar > T(0)) return UnderlyingTypeOf<T>(1);
if(scalar < T(0)) return UnderlyingTypeOf<T>(-1);
return UnderlyingTypeOf<T>(0);
template<class T> constexpr inline typename std::enable_if<IsScalar<T>::value, UnderlyingTypeOf<T>>::type sign(T x) {
using U = UnderlyingTypeOf<T>;
return U(U(bool(x > T(0))) - U(bool(x < T(0))));
}
/** @overload */

Loading…
Cancel
Save