disabling unary "-" for unsigned types

Ellery Newcomer ellery-newcomer at utulsa.edu
Tue Feb 16 11:11:49 PST 2010


On 02/16/2010 12:03 PM, Adam D. Ruppe wrote:
> On Tue, Feb 16, 2010 at 11:26:37AM -0600, Ellery Newcomer wrote:
>> OT: has anyone written a wrapper for int/long/etc that throws exceptions
>> on overflow/underflow? Maybe such a thing should exist in the standard
>> library?
>
> Something along these lines should work (pasted at bottom of message).
>
> I'd like it a lot more if it could just be opBinary!(string)() -- the struct
> would be tiny.
>
> Suckily, assigning an it to it when declaring it doesn't work. I think there's
> a way around this, but I don't know.
>
> The opPow's are commented out since my dmd is too old, so I couldn't test it.
>
>
> ========
>

Awesome. It doesn't work for opPow, though.

And aha! put a static opCall in conjunction with opAssign and you can 
assign when declaring it. This ought to be in the docs somewhere where I 
can find it..



More information about the Digitalmars-d mailing list