Say I have something like this:
void myFunk(std::vector<T>& v, std::vector<T>::iterator first, std::vector<T>::iterator last) {
while (first != last) {
if ((*first) > (*last)) {
T someT;
v.push_back(someT);
}
first++;
}
}
int main(){
std::vector<T> foo = {some, T, values};
myFunky(foo, foo.begin(), foo.end())
return 0;
}
Would this lead to an infinite loop, or would it end after foo.size()
iterations? In other words, would the last
iterator be updated as foo
grew, or would it retain the value given in the function call?
I'm assuming last
would change, since it's a pointer to a position, but would like some confirmation.