moveFront

Moves the front of r out and returns it.

If r.front is a struct with a destructor or copy constructor defined, it is reset to its .init value after its value is moved. Otherwise, it is left unchanged.

In either case, r.front is left in a destroyable state that does not allocate any resources.

Examples

auto a = [ 1, 2, 3 ];
assert(moveFront(a) == 1);
assert(a.length == 3);

// define a perfunctory input range
struct InputRange
{
    enum bool empty = false;
    enum int front = 7;
    void popFront() {}
    int moveFront() { return 43; }
}
InputRange r;
// calls r.moveFront
assert(moveFront(r) == 43);

Meta