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