This is perfectly true since vector::iterator is a random access iterator. You can perform arithmetic operations on it, and it is platform independent.
std::vector<double>::iterator it = A.end(); while (it != A.begin()){ --it;
But A.end() refers to a theoretical A.end() element, therefore, it does not indicate the element and, therefore, should not be dereferenced. Therefore, it is best to use a reverse iterator instead of a decrementing final iterator.
for(std::vector<double>::reverse_iterator it = A.rbegin(); it != A.rend(); ++it) {
These two loops do the same thing, the second is just a clear, cleaner way to do it.
source share