The following snippet produces an infinite loop:
vector<int> nums = {};
for (int i=0; i<(nums.size()-1); ++i) {
cout << i << endl;
}
while the following, correctly, does not even start:
for (int i=0; i<int(nums.size()-1); ++i) {
cout << i << endl;
}
Why?