Take the 2-minute tour ×

In c++ STL, if I have an iterator it into a vector v, is it - v.begin() guaranteed to give me the index into the vector, so that *it == v[it - v.begin()]? If so, is this true for all random access iterators?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Yes, it is, and it is true for all RA iterators.

share|improve this answer
Table 76 in the C++03 standard provides the requirements for random access iterators that make the relationship guarantees. –  Michael Burr Jul 1 '12 at 9:02

Your Answer


