Skip to content

Instantly share code, notes, and snippets.

@dwburke
Last active August 2, 2017 18:51
Show Gist options
  • Save dwburke/c5560908f4d5b2be694209388a6344a8 to your computer and use it in GitHub Desktop.
Save dwburke/c5560908f4d5b2be694209388a6344a8 to your computer and use it in GitHub Desktop.
Delete while iterating std::list
for (auto i = list.begin(); i != list.end();) {
if (condition)
i = list.erase(i);
else
++i;
}
or
list.remove_if([](auto& i) { return i > 10; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment