diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index f358cd51c0..2cd3c4594e 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -399,10 +399,9 @@ template inline Vector clamp(const Vector 0, `0` if @p x = 0 and `-1` if @p x < 0. */ -template inline typename std::enable_if::value, UnderlyingTypeOf>::type sign(T scalar) { - if(scalar > T(0)) return UnderlyingTypeOf(1); - if(scalar < T(0)) return UnderlyingTypeOf(-1); - return UnderlyingTypeOf(0); +template constexpr inline typename std::enable_if::value, UnderlyingTypeOf>::type sign(T x) { + using U = UnderlyingTypeOf; + return U(U(bool(x > T(0))) - U(bool(x < T(0)))); } /** @overload */