diff --git a/src/client_manager.cc b/src/client_manager.cc index d1ac5bf3..f46d16ea 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -170,13 +170,13 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer) client->context().forget_buffer(buffer); Vector> removed_windows; - m_free_windows.erase(std::remove_if(m_free_windows.begin(), m_free_windows.end(), - [&buffer, &removed_windows](WindowAndSelections& ws) { - if (&ws.window->buffer() != &buffer) - return false; - removed_windows.push_back(std::move(ws.window)); - return true; - }), + m_free_windows.erase(remove_if(m_free_windows, + [&buffer, &removed_windows](WindowAndSelections& ws) { + if (&ws.window->buffer() != &buffer) + return false; + removed_windows.push_back(std::move(ws.window)); + return true; + }), m_free_windows.end()); for (auto&& removed_window : removed_windows) diff --git a/src/hook_manager.cc b/src/hook_manager.cc index d27bf731..6e3ae178 100644 --- a/src/hook_manager.cc +++ b/src/hook_manager.cc @@ -36,14 +36,12 @@ void HookManager::remove_hooks(const Regex& regex) { for (auto& list : m_hooks) { - list.erase(std::remove_if(list.begin(), list.end(), - [this, ®ex](std::unique_ptr& h) { - if (not regex_match(h->group.begin(), h->group.end(), regex)) - return false; - m_hooks_trash.push_back(std::move(h)); - return true; - }), - list.end()); + list.erase(remove_if(list, [this, ®ex](std::unique_ptr& h) { + if (not regex_match(h->group.begin(), h->group.end(), regex)) + return false; + m_hooks_trash.push_back(std::move(h)); + return true; + }), list.end()); } } diff --git a/src/line_modification.cc b/src/line_modification.cc index 47e11e64..3e84fe50 100644 --- a/src/line_modification.cc +++ b/src/line_modification.cc @@ -142,7 +142,7 @@ void LineRangeSet::update(ConstArrayView modifs) } } }; - erase(std::remove_if(begin(), end(), [](auto& r) { return r.begin >= r.end; }), end()); + erase(remove_if(*this, [](auto& r) { return r.begin >= r.end; }), end()); } void LineRangeSet::add_range(LineRange range, FunctionRef on_new_range) diff --git a/src/ranges.hh b/src/ranges.hh index 2f288d0f..bd3edd9b 100644 --- a/src/ranges.hh +++ b/src/ranges.hh @@ -428,6 +428,13 @@ bool any_of(Range&& range, T op) return std::any_of(begin(range), end(range), op); } +template +auto remove_if(Range&& range, T op) +{ + using std::begin; using std::end; + return std::remove_if(begin(range), end(range), op); +} + template void unordered_erase(Range&& vec, U&& value) {