add forgotten file again

pull/1576/head
Jeff Becker 3 years ago
parent 2fa24b5eae
commit b01e20b4cb
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -0,0 +1,23 @@
#pragma once
#include <algorithm>
namespace llarp::util
{
/// remove items from a container if a predicate is true
/// return the number of items removed
constexpr auto erase_if = [](auto& container, auto&& pred) -> std::size_t {
std::size_t removed = 0;
for (auto itr = container.begin(); itr != container.end();)
{
if (pred(*itr))
{
itr = container.erase(itr);
removed++;
}
else
itr++;
}
return removed;
};
} // namespace llarp::util
Loading…
Cancel
Save