Annoyance with new integer promotion deprecations
Dominikus Dittes Scherkl
dominikus.scherkl at continental-corporation.com
Wed Feb 7 11:30:02 UTC 2018
On Wednesday, 7 February 2018 at 01:06:42 UTC, Luís Marques wrote:
> On Wednesday, 7 February 2018 at 00:24:26 UTC, H. S. Teoh wrote:
>> I really like your .nx idea! It neatly sidesteps the
>> nonsensical mandatory casts and on top of that documents
>> intent (the .nx being a telltale sign of truncation -- much
>> better than arbitrary implicit rules).
[...]
> Yeah, it's just a thin wrapper. I implemented just enough to
> cover my use cases but just in case it's useful to you or
> someone else, here goes my implementation...
Very cool! Much better than implementing new types.
Just
> auto opBinary(string op, U)(NX!U rhs)
> {
> static if(rhs.value.sizeof > value.sizeof)
> return mixin("rhs " ~ op ~ " value");
That won't do anything good for operators that are NOT commutative
(like -, ^^, <<, >>, %, /, ...)
Seems you don't use other things than +, *, &, | and ^, do you?
More information about the Digitalmars-d
mailing list