mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
AK: Introduce Indexable concept
This was dearly missing and can be used in many existing templates.
This commit is contained in:
parent
af1c26f05b
commit
bbb256e8b5
Notes:
sideshowbarker
2024-07-17 03:22:24 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/bbb256e8b5 Pull-request: https://github.com/SerenityOS/serenity/pull/15992 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/TobyAsE Reviewed-by: https://github.com/idispatch ✅
@ -79,6 +79,16 @@ concept ArrayLike = requires(ArrayT array, SizeT index)
|
||||
-> SameAs<RemoveReference<ContainedT>*>;
|
||||
};
|
||||
|
||||
// Any indexable data structure.
|
||||
template<typename ArrayT, typename ContainedT, typename SizeT = size_t>
|
||||
concept Indexable = requires(ArrayT array, SizeT index)
|
||||
{
|
||||
{
|
||||
array[index]
|
||||
}
|
||||
-> OneOf<RemoveReference<ContainedT>&, RemoveReference<ContainedT>>;
|
||||
};
|
||||
|
||||
template<typename Func, typename... Args>
|
||||
concept VoidFunction = requires(Func func, Args... args)
|
||||
{
|
||||
@ -130,6 +140,7 @@ using AK::Concepts::Enum;
|
||||
using AK::Concepts::FallibleFunction;
|
||||
using AK::Concepts::FloatingPoint;
|
||||
using AK::Concepts::Fundamental;
|
||||
using AK::Concepts::Indexable;
|
||||
using AK::Concepts::Integral;
|
||||
using AK::Concepts::IterableContainer;
|
||||
using AK::Concepts::IteratorFunction;
|
||||
|
Loading…
Reference in New Issue
Block a user