I'm almost certain that I can rely on it, but just to be sure...
For example:
Code:
int main()
{
srand(time(nullptr));
std::vector<int> vi = {1,4,4,1,1};
for(auto x = vi.begin(); x!=vi.end(); x++)
{
int i=rand()%6;
if(i==1||i==4)
vi.push_back(i);
}
for(auto x:vi)
std::cout<<x<<std::endl;
}
It iterates over the modified vector in my case. (even after changing some compiler options manually).
Is that standard/portable behaviour or is the compiler free to stop iterating at the original end iterator ?
Does volatile solve anything if the later is the case ?