New integer promotion rules
Rubn
where at is.this
Wed Jan 17 21:12:07 UTC 2018
On Wednesday, 17 January 2018 at 20:30:07 UTC, rumbu wrote:
> And here is why is bothering me:
>
> auto max = isNegative ? cast(Unsigned!T)(-T.min) :
> cast(Unsigned!T)T.max);
>
> The generic code above (which worked for all signed integral
> types T in 2.077) must be rewritten like this in 2.078:
>
> static if (T.sizeof >= 4)
> auto max = isNegative ? cast(Unsigned!T)(-T.min) :
> cast(Unsigned!T)T.max;
> else
> auto max = isNegative ? cast(Unsigned!T)(-cast(int)T.min) :
> cast(Unsigned!T)T.max;
>
> Now I have to translate an 1-liner in a 4-liner all around my
> project.
Or write some wrapper code, which you prob should have done in
the first place if you use that all around your project:
auto max = myMaxFunc!(isNegative, T);
More information about the Digitalmars-d-learn
mailing list