2021-01-15 01:36:23 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-15 01:36:23 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-07-22 17:41:00 +03:00
|
|
|
#include <AK/Concepts.h>
|
2021-06-12 02:57:46 +03:00
|
|
|
#include <AK/Find.h>
|
2021-01-15 01:36:23 +03:00
|
|
|
#include <AK/Iterator.h>
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
2021-07-22 17:49:34 +03:00
|
|
|
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator>
|
2022-06-26 19:19:34 +03:00
|
|
|
[[nodiscard]] constexpr bool any_of(
|
2021-07-22 17:49:34 +03:00
|
|
|
TIterator const& begin,
|
|
|
|
TEndIterator const& end,
|
2021-07-22 17:43:56 +03:00
|
|
|
auto const& predicate)
|
2021-01-15 01:36:23 +03:00
|
|
|
{
|
2021-06-12 02:57:46 +03:00
|
|
|
return find_if(begin, end, predicate) != end;
|
2021-01-15 01:36:23 +03:00
|
|
|
}
|
|
|
|
|
2021-07-22 17:41:00 +03:00
|
|
|
template<IterableContainer Container>
|
2022-06-26 19:19:34 +03:00
|
|
|
[[nodiscard]] constexpr bool any_of(Container&& container, auto const& predicate)
|
2021-07-22 17:41:00 +03:00
|
|
|
{
|
2021-07-25 21:56:52 +03:00
|
|
|
return any_of(container.begin(), container.end(), predicate);
|
2021-07-22 17:41:00 +03:00
|
|
|
}
|
|
|
|
|
2021-01-15 01:36:23 +03:00
|
|
|
}
|
2021-02-07 13:35:08 +03:00
|
|
|
|
|
|
|
using AK::any_of;
|