mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
24225df979
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`.
25 lines
462 B
C++
25 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;
|