Created
December 7, 2013 17:34
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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