Advance iterator for the std::vector std::advance VS operator +?

Viewed 10746

I found myself writing the following a lot:

int location =2;
vector<int> vec;
vector<int>::iterator it=vec.begin();

/..../
std::advance(it, location);

instead of

 it= it + 5;

what is the Preferred/Recommended way ?

7 Answers
Related