On Saturday, 23 May 2015 at 17:17:17 UTC, Andrei Alexandrescu wrote:
On 5/21/15 2:35 PM, Ali Çehreli wrote:
On 05/21/2015 12:44 PM, Meta wrote:

All we need is user-defined opIs and then we're really cooking with gas.

if (5 is between(4, 6))
{
    //...
}


We're almost there. :)

bool is_between(T0, T1, T2)(T0 what, T1 min, T2 max)
{
    return (what >= min) && (what <= max);
}

void main()
{
    if (5.is_between(4, 6)) {
        // ...
    }
}

In fact we'll be there with 2.068:

http://dlang.org/phobos-prerelease/std_algorithm_sorting.html#.ordered

if (ordered(4, 5, 6)) { ... }
if (strictlyOrdered(4, 5, 6)) { ... }


Andrei

I didn't realize this got pulled, I remember it being discussed a while back on the general NG. Good addition.

Reply via email to