Reorder abs constraints to avoid the integral promotion deprecation message

This commit is contained in:
Sebastian Wilzbach 2018-08-15 12:16:34 +02:00
parent eabbc8e949
commit d9e4524e06

View file

@ -628,8 +628,8 @@ template isDeprecatedComplex(T)
*/ */
auto abs(Num)(Num x) auto abs(Num)(Num x)
if (!isDeprecatedComplex!Num && if (!isDeprecatedComplex!Num &&
(is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) || (is(Unqual!Num == short) || is(Unqual!Num == byte)) ||
(is(Unqual!Num == short) || is(Unqual!Num == byte)))) (is(typeof(Num.init >= 0)) && is(typeof(-Num.init))))
{ {
static if (isFloatingPoint!(Num)) static if (isFloatingPoint!(Num))
return fabs(x); return fabs(x);
@ -723,7 +723,7 @@ static foreach (Num; AliasSeq!(cfloat, cdouble, creal, ifloat, idouble, ireal))
{ {
return v; return v;
} }
Vector!(float, 3) v; Vector!(int, 3) v;
assert(abs(v) == v); assert(abs(v) == v);
} }