A range based on a loop creates code similar to this:
{ auto && __range = range_expression ; for (auto __begin = begin_expr,__end = end_expr; __begin != __end; ++__begin) { range_declaration = *__begin; loop_statement } }
As you can see, the range will not be updated as your container is reused.
In addition, you will most likely end up with undefined behavior, because since you drop the values ββin vector these iterators will be invalid if you resize.
See @ user2079303 for a better way to populate your vector .
source share