diff --git a/AK/AllOf.h b/AK/AllOf.h index 96a612decb2..a551046b977 100644 --- a/AK/AllOf.h +++ b/AK/AllOf.h @@ -11,10 +11,10 @@ namespace AK { -template +template TIterator> constexpr bool all_of( - SimpleIterator const& begin, - SimpleIterator const& end, + TIterator const& begin, + TEndIterator const& end, auto const& predicate) { for (auto iter = begin; iter != end; ++iter) { diff --git a/AK/AnyOf.h b/AK/AnyOf.h index 97bacefd462..f651f3eec62 100644 --- a/AK/AnyOf.h +++ b/AK/AnyOf.h @@ -12,10 +12,10 @@ namespace AK { -template +template TIterator> constexpr bool any_of( - SimpleIterator const& begin, - SimpleIterator const& end, + TIterator const& begin, + TEndIterator const& end, auto const& predicate) { return find_if(begin, end, predicate) != end; diff --git a/AK/Find.h b/AK/Find.h index f0f3359172c..7fe7f666bb4 100644 --- a/AK/Find.h +++ b/AK/Find.h @@ -6,13 +6,14 @@ #pragma once +#include #include #include namespace AK { -template -constexpr TIterator find_if(TIterator first, TIterator last, TUnaryPredicate&& pred) +template TIterator, typename TUnaryPredicate> +constexpr TIterator find_if(TIterator first, TEndIterator last, TUnaryPredicate&& pred) { for (; first != last; ++first) { if (pred(*first)) { @@ -22,16 +23,16 @@ constexpr TIterator find_if(TIterator first, TIterator last, TUnaryPredicate&& p return last; } -template -constexpr TIterator find(TIterator first, TIterator last, const T& value) +template TIterator, typename T> +constexpr TIterator find(TIterator first, TEndIterator last, T const& value) { - return find_if(first, last, [&](const auto& v) { return Traits::equals(value, v); }); + return find_if(first, last, [&](auto const& v) { return Traits::equals(value, v); }); } -template -constexpr size_t find_index(TIterator first, TIterator last, const T& value) +template TIterator, typename T> +constexpr size_t find_index(TIterator first, TEndIterator last, T const& value) requires(requires(TIterator it) { it.index(); }) { - return find_if(first, last, [&](const auto& v) { return Traits::equals(value, v); }).index(); + return find_if(first, last, [&](auto const& v) { return Traits::equals(value, v); }).index(); } }