whenEmpty

Undocumented in source. Be warned that the author may not have intended to support it.
  1. auto whenEmpty(R range)
    whenEmpty
    (
    alias func
    R
    )
    ()
    if (
    isInputRange!R &&
    isCallable!func
    )
  2. auto whenEmpty(R range, Fn fn)

Examples

{
    static auto arrA = [1, 2, 3];
    auto r = arrA.whenEmpty!((){ arrA = null; });
    assert(equal(r, arrA));
    assert(arrA is null);
}
{
    static auto arrB = [1, 2, 3];
    auto r = arrB.whenEmpty!((){ arrB = null; });
    //assert(equal(r, arr));
    r.popFront(); r.popFront();
    assert(arrB !is null);
    r.popFront();
    assert(arrB is null);
}

Meta