---
title: llarp/util/algorithm.hpp

---

# llarp/util/algorithm.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::util](Namespaces/namespacellarp_1_1util.md)**  |




## Source code

```cpp
#pragma once

#include <algorithm>

namespace llarp::util
{
  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
```


-------------------------------

Updated on 2023-01-26 at 19:35:18 +0000
