Sure, but that's not as clear.
Sure, but that's not as clear.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
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. } }
Last edited by CornedBee; 11-02-2007 at 03:41 PM.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
My rule of thumb for unsigned values being reverse iterated is to use a do...while.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
> 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?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.