Continuing with reversible ranges:
struct ForwardRange {
_start;
_end;
BackwardRange reverse() { return BackwardRange( _end, _start ); }
}
struct BackwardRange {
_start;
_end;
//guess what reverse is.
}
That would give the power to mimick bidirectional ranges (see
post on popBack before)
Now, we still need a way to move one of those pointers to a given
place to fulfill rfind:
auto rfind( R, E )( R r, E e ) if( isReversibleRange!R ) {
auto original = r.save; //For the end purpose;
auto found = find( r.reverse, e ); //found is reversed and
starts on e.
//What we want now is a range of type typeof( original )
starting on found but ending on original. Therefore, we need an
additional primitive. Suggestion: jumpTo.
return original.jumpTo( found ); //Keeps the ordering, only move
the start.
}
struct ForwardRange {
...
void jumpTo( ForwardRange r )( _start = r._start; }
void jumpTo( BackwardRange r )( _start = r._start; }
}