erase.hpp 372 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
#ifndef RTG_GUARD_ERASE_HPP
#define RTG_GUARD_ERASE_HPP

namespace rtg {

Paul's avatar
Paul committed
6
template <class R, class T>
Paul's avatar
Paul committed
7
8
auto erase(R&& r, const T& value)
{
Paul's avatar
Paul committed
9
    return r.erase(std::remove(r.begin(), r.end(), value), r.end());
Paul's avatar
Paul committed
10
11
}

Paul's avatar
Paul committed
12
template <class R, class P>
Paul's avatar
Paul committed
13
14
auto erase_if(R&& r, P&& pred)
{
Paul's avatar
Paul committed
15
    return r.erase(std::remove_if(r.begin(), r.end(), pred), r.end());
Paul's avatar
Paul committed
16
17
18
19
20
}

} // namespace rtg

#endif