What if I increment an iterator by 2 when it points onto the last element of a vector? In this question asking how to adjust the iterator to an STL container by 2 elements t
The code that Marijn suggests is just slightly wrong (as curiousguy pointed out).
The correct version of the last line is:
bool isPastEnd = it >= vec.end();
I suggest you to take a look at Boost.Range. It might be safer to use. It will also be in C++0x.