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.
This commit is contained in:
Lenny Maiorani 2020-11-22 17:09:44 -07:00 committed by Andreas Kling
parent 34e9df3c5e
commit 4421d98e30

View file

@ -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)) {