Skip to content

Instantly share code, notes, and snippets.

@ilpropheta
Created July 16, 2016 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilpropheta/f7b9a63216edbae8ac0ba5eb5f74a897 to your computer and use it in GitHub Desktop.
Save ilpropheta/f7b9a63216edbae8ac0ba5eb5f74a897 to your computer and use it in GitHub Desktop.
template <typename Assoc, typename UnaryPred>
void erase_if(Assoc& container, UnaryPred p)
{
for (auto it = begin(container); it != end(container); )
{
if (p(*it))
it = container.erase(it);
else
++it;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment