diff --git a/AK/Concepts.h b/AK/Concepts.h index 5101f9d426..94136dfc11 100644 --- a/AK/Concepts.h +++ b/AK/Concepts.h @@ -41,6 +41,32 @@ concept HashCompatible = IsHashCompatible, Detail::Decay>; // FIXME: remove once Clang formats these properly. // clang-format off + +// Any indexable, sized, contiguous data structure. +template +concept ArrayLike = requires(ArrayT array, SizeT index) +{ + { + array[index] + } + -> SameAs&>; + + { + array.size() + } + -> SameAs; + + { + array.span() + } + -> SameAs>>; + + { + array.data() + } + -> SameAs*>; +}; + template concept VoidFunction = requires(Func func, Args... args) { @@ -77,6 +103,7 @@ concept IterableContainer = requires } using AK::Concepts::Arithmetic; +using AK::Concepts::ArrayLike; using AK::Concepts::Enum; using AK::Concepts::FloatingPoint; using AK::Concepts::Integral;