cmake/Utilities/std/cm/bits/erase_if.hxx

27 lines
571 B
C++
Raw Normal View History

2020-08-30 11:54:41 +02:00
// -*-c++-*-
// vim: set ft=cpp:
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2020-08-30 11:54:41 +02:00
namespace cm {
namespace internals {
template <typename Container, typename Predicate>
void erase_if(Container& cont, Predicate pred)
{
for (typename Container::iterator iter = cont.begin(), last = cont.end();
iter != last;) {
if (pred(*iter)) {
iter = cont.erase(iter);
} else {
++iter;
}
}
}
} // namespace internals
} // namespace cm