On Monday, 19 February 2018 at 13:33:34 UTC, rikki cattermole wrote:
https://dlang.org/phobos/std_experimental_checkedint.html#.Checked.min


Can't seem to get that to work, so I assumed it's not meant to be used that way:

import std.experimental.checkedint;

struct MyHook {
    enum min(T) = 3;
    enum max(T) = 15;

    static B onLowerBound(T, B)(T value, B bound)
    {
        assert(0);
    }

    static B onUpperBound(T, B)(T value, B bound)
    {
        assert(0);
    }
}

unittest
{
    Checked!(int, MyHook) a;
    a = 22;
    assert(a != 22); // This assert triggers, not the others.
}

--
  Simen

Reply via email to