1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-05 23:14:54 +00:00
serenity/AK/AnyOf.h
Andreas Kling ae3ffdd521 AK: Make it possible to not using AK classes into the global namespace
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by
default, but can be overridden by build flags.

This is a step towards integrating Jakt and AK types.
2022-11-26 15:51:34 +01:00

35 lines
695 B
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Concepts.h>
#include <AK/Find.h>
#include <AK/Iterator.h>
namespace AK {
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator>
[[nodiscard]] constexpr bool any_of(
TIterator const& begin,
TEndIterator const& end,
auto const& predicate)
{
return find_if(begin, end, predicate) != end;
}
template<IterableContainer Container>
[[nodiscard]] constexpr bool any_of(Container&& container, auto const& predicate)
{
return any_of(container.begin(), container.end(), predicate);
}
}
#if USING_AK_GLOBALLY
using AK::any_of;
#endif