diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2020-11-22 17:09:44 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-20 21:13:10 +0100 |
commit | 4421d98e30763424055eefe729c9cab28abdf19d (patch) | |
tree | f3b6b5b80e745813dbb1dfe30b999489d414e3ac | |
parent | 34e9df3c5e41c923faf518f45e8302e997021d4b (diff) | |
download | serenity-4421d98e30763424055eefe729c9cab28abdf19d.zip |
AllOf: Common iterator types
Problem:
- Interface is too permissive. It permits iterators of different types
as long as they are comparable.
Solution:
- Require iterators be the same type.
-rw-r--r-- | AK/AllOf.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/AK/AllOf.h b/AK/AllOf.h index 8e2f94df1c..5fe698b0f2 100644 --- a/AK/AllOf.h +++ b/AK/AllOf.h @@ -26,9 +26,15 @@ #pragma once +#include <AK/Iterator.h> + namespace AK { -constexpr bool all_of(const auto& begin, const auto& end, const auto& predicate) +template<typename Container, typename ValueType> +constexpr bool all_of( + const SimpleIterator<Container, ValueType>& begin, + const SimpleIterator<Container, ValueType>& end, + const auto& predicate) { for (auto iter = begin; iter != end; ++iter) { if (!predicate(*iter)) { |