Implement erase_if() for Unordered via function template in detail namespace

This commit is contained in:
Christian Mazakas
2022-02-23 11:36:48 -08:00
parent d943283f80
commit c322cc5621
5 changed files with 63 additions and 0 deletions
@@ -4360,6 +4360,25 @@ namespace boost {
typedef typename pick::bucket bucket;
typedef typename pick::link_pointer link_pointer;
};
template <class Container, class Predicate>
typename Container::size_type erase_if(Container& c, Predicate& pred)
{
typedef typename Container::size_type size_type;
typedef typename Container::iterator iterator;
size_type const size = c.size();
for (iterator pos = c.begin(), end = c.end(); pos != end;) {
if (pred(*pos)) {
pos = c.erase(pos);
} else {
++pos;
}
}
return (size - c.size());
}
}
}
}