diff options
author | vng <viktor.govako@gmail.com> | 2016-03-23 18:08:38 +0300 |
---|---|---|
committer | vng <viktor.govako@gmail.com> | 2016-03-24 03:45:36 +0300 |
commit | b4bdf2d98239bc82331115d13140cc7d0f59da50 (patch) | |
tree | 133f931a84259b800dd182a4ba7178857c994850 /base | |
parent | e05501259e9f5d917dd83159b6dc162852c984e6 (diff) |
Added EraseIf helper.
Diffstat (limited to 'base')
-rw-r--r-- | base/stl_helpers.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/base/stl_helpers.hpp b/base/stl_helpers.hpp index f4f3ca3b97..3375867f75 100644 --- a/base/stl_helpers.hpp +++ b/base/stl_helpers.hpp @@ -45,12 +45,18 @@ struct Comparer<false, T, C> // Sorts and removes duplicate entries from |v|. template <typename T> -void SortUnique(std::vector<T> & v) +void SortUnique(vector<T> & v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); } +template <typename T, class TFn> +void EraseIf(vector<T> & v, TFn && fn) +{ + v.erase(remove_if(v.begin(), v.end(), forward<TFn>(fn)), v.end()); +} + // Creates a comparer being able to compare two instances of class C // (given by reference or pointer) by a field or const method of C. // For example, to create comparer that is able to compare pairs of |