Reverse iterators have a member base()
which returns a corresponding forward iterator. Beware that this isn’t an iterator that refers to the same object – it actually refers to the next object in the sequence. This is so that rbegin()
corresponds with end()
and rend()
corresponds with begin()
.
So if you want to return an iterator, then you would do something like
std::deque<Move>::const_iterator Current() const
{
if (forward)
return currentfwd;
else
return (currentbck+1).base();
}
I would prefer to return a reference, though, and encapsulate all the iteration details inside the class.