Tested, and working. But I wonder if this is the right approach:
a vector is cool but maybe a list is great after all?
supports arbitrary nesting of safe_iteration, which seems overkill
supports removal of items other than the "currently iterated over"
(this is untested as the old code path didn't support it).
doesn't support "clear" while safe iterating
"safe iteration" is a modification_safe_for_each, not general-purpose
iteration. Should probably support any kind of iteration.
I'm thinking this pattern is common enough that we should come up with a
decent solution that "just works" in all cases. I would like to be able
to write:
ranges::for_each(container, [](auto &elem) { if (elem.bad()) container.remove(elem); }
and have it "Just Work". Maybe that's overkill, it's certainly atypical C++ code.
The old code is a bit split-brained about whether it used it = it->next or it = it_next,
and the old code also didn't support multiple removals during iteration (see
for example #182).
Tested, and working. But I wonder if this is the right approach:
I'm thinking this pattern is common enough that we should come up with a decent solution that "just works" in all cases. I would like to be able to write:
and have it "Just Work". Maybe that's overkill, it's certainly atypical C++ code.
The old code is a bit split-brained about whether it used
it = it->next
orit = it_next
, and the old code also didn't support multiple removals during iteration (see for example #182).