serenity/AK/AnyOf.h
Lenny Maiorani 24225df979 AK: Reimplement any_of in terms of find_if
Problem:
- Now that a generic free-function form of `find_if` is implemented
  the code in `any_of` is redundant.

Solution:
- Follow the "don't repeat yourself" mantra and make the code DRY by
  implementing `any_of` in terms of `find_if`.
2021-06-20 10:54:09 +01:00

26 lines
462 B
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Find.h>
#include <AK/Iterator.h>
namespace AK {
template<typename Container, typename ValueType>
constexpr bool any_of(
const SimpleIterator<Container, ValueType>& begin,
const SimpleIterator<Container, ValueType>& end,
const auto& predicate)
{
return find_if(begin, end, predicate) != end;
}
}
using AK::any_of;