Sure, but that's not as clear.
Printable View
Sure, but that's not as clear.
I never had problems iterating in reverse ;)
Code:template <typename BidiRange>
void foo(BidiRange &rr)
{
for(typename range_reverse_iterator<BidiRange>::type ri = rbegin(rr), re = rend(rr); ri != re; ++ri) {
// Whatever.
}
}
Sure, but that requires the use of iterators. Sometimes subscripting is more convenient. Unless you're making the argument that subscripting should never be used to iterate through each value an array -- forwards or backwards.
My rule of thumb for unsigned values being reverse iterated is to use a do...while.
> But that creates a pointer value which is undefined, according to the standard.
Yes, just as "undefined" as your negative subscript - what's your point?