_integralAbs

Copied from std.numeric to prevent unnecessary Phobos deps.

pure nothrow pragma(inline, true)
T
_integralAbs
(
T
)
(
T x
)

Examples

as hash table key

// TODO disabled until non-copyable types work in AA's
// string[Z] aa;
// aa[123.Z] = "abc";
// aa[456.Z] = "def";
// assert(aa[123.Z] == "abc");
// assert(aa[456.Z] == "def");

copyable integer

alias CZ = CopyableMpZ;

CZ a = 42;

CZ b = a;                   // copy
assert(a == b);             // should equal
assert(a !is b);            // but not the same

CZ c = null;                // other value
assert(a != c);             // should diff

to string conversion

for (int i = -100; i < 100; ++i)
{
    import std.conv : to;
    assert(i.Z.toString == i.to!string);
}

Meta