On 2010-02-15 17:21:09 -0500, Walter Bright <newshou...@digitalmars.com> said:
Or: -cast(int)xThat 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 michel.for...@michelf.com http://michelf.com/