mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
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:
parent
34e9df3c5e
commit
4421d98e30
1 changed files with 7 additions and 1 deletions
|
@ -26,9 +26,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Iterator.h>
|
||||||
|
|
||||||
namespace AK {
|
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) {
|
for (auto iter = begin; iter != end; ++iter) {
|
||||||
if (!predicate(*iter)) {
|
if (!predicate(*iter)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue