symmetric signed types

Dominikus Dittes Scherkl Dominikus.Scherkl at continental-corporation.com
Thu Jan 23 08:54:28 PST 2014


On Thursday, 23 January 2014 at 16:52:14 UTC, Stanislav Blinov 
wrote:
> 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... +/ }

Cool. So why it that not used in std.math.abs?


More information about the Digitalmars-d mailing list