On Saturday, 20 September 2014 at 19:23:46 UTC, Jakob Ovrum wrote:
If you want move semantics, use `moveFront`.

But x.moveFront doesn't modify x.

What I want is to transform my uses of std.range from

if (!x.empty)
{
    x.front.doStuff;
    x.popFront;
}

into

if (!x.empty)
    if (auto front = x.stealFront)
    {
        front.doStuff;
    }

This is more functional/atomic, that is it reduces the risk of accidentally forgetting to call popFront at the end.

Destroy!

Reply via email to