On Monday, 16 December 2013 at 20:38:52 UTC, Andrei Alexandrescu wrote:
bool between(T, U1, U2)(T v, U1 lo, U2 hi)
{
    return v >= lo && v <= hi;
}

Careful:

assert(between(0u, -1, 1)); // fails

Assuming no overflows, a faster implementation would be:

return v-lo <= hi-lo;

Reply via email to