New integer promotion rules

rumbu rumbu at rumbu.ro
Wed Jan 17 20:30:07 UTC 2018


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.





More information about the Digitalmars-d-learn mailing list