Error on negating unsigned types

Johan Engelen via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 12 14:24:05 PDT 2017


On Wednesday, 12 July 2017 at 20:12:03 UTC, Steven Schveighoffer 
wrote:
>...
> Which means this may cause a bunch of nuisance errors.

It's a trade-off between nuisance in some cases (the Phobos ones 
can be solved with val = abs(val), or with static if), and 
possibly catching bugs in other cases.

We can compare this with negation of a bool and subtracting a 
bool:
```
bool b;
auto x = 1 - b; // allowed
auto y = -b; // not allowed
```



More information about the Digitalmars-d mailing list