summary refs log tree commit diff stats
path: root/src/util.h
blob: 150a6a5fd86fb72258c27f9b70f90e8a056064a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef UTIL_H_E9110D4C
#define UTIL_H_E9110D4C

template <typename Container, typename Predicate>
void erase_if(Container& items, const Predicate& predicate)
{
  for (auto it = std::begin(items); it != std::end(items);)
  {
    if (predicate(*it))
    {
      it = items.erase(it);
    }
    else
    {
      ++it;
    }
  }
};

#endif /* end of include guard: UTIL_H_E9110D4C */