short s, t; t = -s: no (longer) works: Deprecation: integral promotion not done for -s, use
Steven Schveighoffer
schveiguy at yahoo.com
Sat Feb 24 20:17:12 UTC 2018
On 2/24/18 3:07 PM, kdevel wrote:
> I don't get the point of the deprecation message:
>
> --- intprom.d
> import std.stdio;
>
> void main ()
> {
> short s, t;
> t = -s;
> }
> ---
https://dlang.org/changelog/2.078.0.html#fix16997
>
> $ dmd intprom.d
> intprom.d(6): Deprecation: integral promotion not done for -s, use
> '-transition=intpromote' switch or -cast(int)(s)
>
> What shall I do in order to get my template code
>
> void mymain (T) ()
> {
> :
> b[i] = -b [i];
> :
> }
>
> compiled for any type for which negation is defined?
b[i] = cast(typeof(b[i]))-b[i];
And then use -transition=intpromote.
Note, your function wasn't real code, so maybe if you have the type of
b[i] somewhere it might look better than what I wrote (like maybe
cast(T)-b[i]).
-Steve
More information about the Digitalmars-d-learn
mailing list