| 1 |
// -*-c++-*- |
| 2 |
// vim: set ft=cpp: |
| 3 |
|
| 4 |
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 5 |
file LICENSE.rst or https://cmake.org/licensing for details. */ |
| 6 |
|
| 7 |
#pragma once |
| 8 |
|
| 9 |
namespace cm { |
| 10 |
namespace internals { |
| 11 |
|
| 12 |
template <typename Container, typename Predicate> |
| 13 |
void erase_if(Container& cont, Predicate pred) |
| 14 |
{ |
| 15 |
for (typename Container::iterator iter = cont.begin(), last = cont.end(); |
| 16 |
iter != last;) { |
| 17 |
if (pred(*iter)) { |
| 18 |
iter = cont.erase(iter); |
| 19 |
} else { |
| 20 |
++iter; |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
} // namespace internals |
| 26 |
} // namespace cm |