Skip to content

Instantly share code, notes, and snippets.

@Experiment5X
Created December 7, 2013 17:34
Show Gist options
  • Save Experiment5X/7845847 to your computer and use it in GitHub Desktop.
Save Experiment5X/7845847 to your computer and use it in GitHub Desktop.
The best way to remove elements from a vector, I got the concept from a video on MSDN by Stephan T. Lavavej about the associative containers in the stl.
template <typename T>
void remove_elements(vector<T> &vect, function<bool(T)> comparator)
{
auto newEnd = remove_if(vect.begin(), vect.end(), comparator);
vect.erase(newEnd, vect.end());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment