On 2010-02-15 17:21:09 -0500, Walter Bright <[email protected]> said:

Or:

    -cast(int)x

That blows when x happens to be a ulong. Whoops. It blows even worse if x turns out to be a struct with overloaded opNeg and opCast, suddenly the opCast gets selected. Oops.

That one is easy to fix. Add a "signed(x)" template function returning the signed counterpart of x. You could even insert a runtime range check if you really wanted to.


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to