1 auto a = [ 1, 2, 3 ]; 2 assert(moveFront(a) == 1); 3 assert(a.length == 3); 4 5 // define a perfunctory input range 6 struct InputRange 7 { 8 enum bool empty = false; 9 enum int front = 7; 10 void popFront() {} 11 int moveFront() { return 43; } 12 } 13 InputRange r; 14 // calls r.moveFront 15 assert(moveFront(r) == 43);
Moves the front of r out and returns it. Leaves r.front in a destroyable state that does not allocate any resources (usually equal to its .init value).