Different container's iterators have different properties. Here are the iterator invalidation rules.
The list loop: When you push onto a list
all previous iterators still valid. You will never hit the end if every time you iterator forward one you also add a new element, obviously.
The vector loop: For a vector, your iterators are invalid once a push_back
results in the new size exceeding the old capacity. As soon as this happens, using iter
is undefined behavior (you will likely crash).
I thought that when the vector container must be resized, it does so at powers of 2 and is located to a new area of memory
This is unspecified by the standard. Some implementations of the C++ standard library double the capacity of a vector when the size exceeds the old capacity, and others grow at different rates.