/* * Copyright (c) 2020, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace AK::Concepts { template concept Integral = IsIntegral; template concept FloatingPoint = IsFloatingPoint; template concept Arithmetic = IsArithmetic; template concept Signed = IsSigned; template concept Unsigned = IsUnsigned; template concept Enum = IsEnum; template concept SameAs = IsSame; template concept AnyString = Detail::IsConstructible; template 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) { { func(args...) } -> SameAs; }; template concept IteratorFunction = requires(Func func, Args... args) { { func(args...) } -> SameAs; }; template concept IteratorPairWith = requires(T it, EndT end) { *it; { it != end } -> SameAs; ++it; }; template concept IterableContainer = requires { { declval().begin() } -> IteratorPairWith().end())>; }; // clang-format on } using AK::Concepts::Arithmetic; using AK::Concepts::ArrayLike; using AK::Concepts::Enum; using AK::Concepts::FloatingPoint; using AK::Concepts::Integral; using AK::Concepts::IterableContainer; using AK::Concepts::IteratorFunction; using AK::Concepts::IteratorPairWith; using AK::Concepts::SameAs; using AK::Concepts::Signed; using AK::Concepts::Unsigned; using AK::Concepts::VoidFunction;