symmetric signed types

Stanislav Blinov stanislav.blinov at gmail.com
Thu Jan 23 08:52:11 PST 2014


On Thursday, 23 January 2014 at 12:09:24 UTC, Dominikus Dittes 
Scherkl wrote:

> Also getting the absolute value of some signed variable
> need to return a different type or doesn't work correct for all 
> input.
> E.g. "ubyte abs(byte)" - this functions which can't even use a 
> template,
> or has anybody a good idea ho to express "unsigned T abs(T)(T 
> x)"?

import std.traits : Unsigned;

Unsigned!T abs(T)(T x) { /+ magic... +/ }


More information about the Digitalmars-d mailing list