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
parent b09595e147
commit 365557ddd7
No known key found for this signature in database
GPG key ID: 49DC70026D2C578C

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;