Following is the quote from Nicolai Josuttis book:
Note that advance() does not check
whether it crosses the end() of a
sequence (it can’t check because
iterators in general do not know the
containers on which they operate).
Thus, calling this function might
result in undefined behavior because
calling operator ++ for the end of a
sequence is not defined
In other words, the responsibility of maintaining the iterator within the range lies totally with the caller.