mattgodbolt / xania

Xania MUD source
Other
58 stars 13 forks source link

Initial work on a vector of "safe to remove" things #199

Closed mattgodbolt closed 4 years ago

mattgodbolt commented 4 years ago

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:

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).

mattgodbolt commented 4 years ago

Closing in favour of #233