AK: Add IterableContainerOf concept

This concept not only checks that the given type is iterable, but it
also checks that the iterated value is of the expected type.
This commit is contained in:
Jonne Ransijn 2024-11-16 23:52:11 +01:00 committed by Sam Atkins
parent e8b2d35410
commit a4f23c512c
Notes: github-actions[bot] 2024-12-04 16:47:08 +00:00

View file

@ -122,6 +122,13 @@ concept IterableContainer = requires {
} -> IteratorPairWith<decltype(declval<T>().end())>;
};
template<typename T, typename ValueT>
concept IterableContainerOf = IterableContainer<T> && requires {
{
*declval<T>().begin()
} -> SameAs<ValueT>;
};
template<typename Func, typename... Args>
concept FallibleFunction = requires(Func&& func, Args&&... args) {
func(forward<Args>(args)...).is_error();
@ -173,6 +180,7 @@ using AK::Concepts::Fundamental;
using AK::Concepts::Indexable;
using AK::Concepts::Integral;
using AK::Concepts::IterableContainer;
using AK::Concepts::IterableContainerOf;
using AK::Concepts::IteratorFunction;
using AK::Concepts::IteratorPairWith;
using AK::Concepts::OneOf;