On Thursday, 8 October 2015 at 14:46:07 UTC, John Colvin wrote:
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`.

my question is: How, in practice, does one take a bidirectional range and make one of these new things? I foresee some difficulty, but perhaps I'm just not being imaginative enough.

It should be probably possible to undo the history range too, but it would be future, so it looks like there can be a better interface: beforeFront returns a normal bidirectional range of items before current front, afterBack returns a normal bidirectional range of items after back, so r.beforeFront.back is an item right before current front. This makes it more symmetric, and properties return ranges of the same type as the source range, but I don't know how to name such a range :) A range with shadows? Those ranges can be seen as shadows (before and after).

Yes D's bidirectional range provides less guarantees than C++ bidirectional iterator, but you can build it on a random access range that provides more guarantees than bidirectional iterator, or you can provide a range with shadows, that provides as much guarantees as C++ bidirectional iterator, no less, no more.

Reply via email to