On Thursday, 8 October 2015 at 13:10:24 UTC, John Colvin wrote:
What you're effectively describing is a trio of iterators wrapped to give an interface of two linked ranges. popFront grows the first one and shrinks the second. I'd be interested to see how to construct that, given a generic range as input.

The C++ example doesn't work with generic iterators, it needs a specific ability to iterate in both directions, hence a bidirectional range.

The way ranges are used for iteration, they can be seen as adapters for iterators providing various consistent interfaces depending on their capabilities. In this example we need a bidirectional range that can go back and forth, one way to do it is to provide undo mechanism like undoPopFront and frontUndoEmpty to allow the range grow back, thus remaining a range that is a list of items and not an iterator. Another way is to provide a reverse range of previously popped items - this can be seen as iterator or not, more like a range with history rather than an undoable input range, so maybe the getter should be `history`.

Reply via email to