There is a set visited. And I wanna check all its elements from 4-th to last.
I’m trying to do something like that
int visited_pointer = 4;
for ( set<int>::iterator i_visited=visited.begin()+visited_pointer
; i_visited!=visited.end()
; i_visited++
)
and got errors with operator+.
How can I do that in the right way?
That usage of
operator+is only provided for random-access iterators.setiterators are bi-directional iterators.But the function
std::advancecan be used to move any iterator a certain number of places: