2020-08-03 14:14:37 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 04:24:48 -04:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-03 14:14:37 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-05-16 05:36:52 -04:00
|
|
|
#include <AK/IterationDecision.h>
|
2020-08-03 14:14:37 -04:00
|
|
|
#include <AK/StdLibExtras.h>
|
|
|
|
|
|
|
|
namespace AK::Concepts {
|
|
|
|
|
|
|
|
template<typename T>
|
2021-04-10 09:59:06 -04:00
|
|
|
concept Integral = IsIntegral<T>;
|
2020-08-03 14:14:37 -04:00
|
|
|
|
|
|
|
template<typename T>
|
2021-04-10 09:59:06 -04:00
|
|
|
concept FloatingPoint = IsFloatingPoint<T>;
|
2020-08-03 14:14:37 -04:00
|
|
|
|
2021-03-19 17:23:48 -04:00
|
|
|
template<typename T>
|
2021-04-10 09:59:06 -04:00
|
|
|
concept Arithmetic = IsArithmetic<T>;
|
2021-03-19 17:23:48 -04:00
|
|
|
|
2021-03-27 17:20:15 -04:00
|
|
|
template<typename T>
|
2021-04-10 09:59:06 -04:00
|
|
|
concept Signed = IsSigned<T>;
|
2021-03-27 17:20:15 -04:00
|
|
|
|
|
|
|
template<typename T>
|
2021-04-10 09:59:06 -04:00
|
|
|
concept Unsigned = IsUnsigned<T>;
|
2021-03-27 17:20:15 -04:00
|
|
|
|
2021-07-04 00:44:34 -04:00
|
|
|
template<typename T>
|
|
|
|
concept Enum = IsEnum<T>;
|
|
|
|
|
2021-05-16 05:36:52 -04:00
|
|
|
template<typename T, typename U>
|
|
|
|
concept SameAs = IsSame<T, U>;
|
|
|
|
|
2021-06-19 07:13:31 -04:00
|
|
|
// FIXME: remove once Clang formats these properly.
|
|
|
|
// clang-format off
|
2021-05-16 05:36:52 -04:00
|
|
|
template<typename Func, typename... Args>
|
|
|
|
concept VoidFunction = requires(Func func, Args... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
func(args...)
|
|
|
|
}
|
2021-06-19 07:13:31 -04:00
|
|
|
-> SameAs<void>;
|
2021-05-16 05:36:52 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Func, typename... Args>
|
|
|
|
concept IteratorFunction = requires(Func func, Args... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
func(args...)
|
|
|
|
}
|
2021-06-19 07:13:31 -04:00
|
|
|
-> SameAs<IterationDecision>;
|
2021-05-16 05:36:52 -04:00
|
|
|
};
|
2021-06-19 07:13:31 -04:00
|
|
|
// clang-format on
|
2020-08-03 14:14:37 -04:00
|
|
|
}
|
2020-12-05 17:25:19 -05:00
|
|
|
|
2021-03-27 17:24:50 -04:00
|
|
|
using AK::Concepts::Arithmetic;
|
2021-07-04 00:44:34 -04:00
|
|
|
using AK::Concepts::Enum;
|
2021-03-27 17:24:50 -04:00
|
|
|
using AK::Concepts::FloatingPoint;
|
|
|
|
using AK::Concepts::Integral;
|
2021-05-16 05:36:52 -04:00
|
|
|
using AK::Concepts::IteratorFunction;
|
2021-03-27 17:20:15 -04:00
|
|
|
using AK::Concepts::Signed;
|
|
|
|
using AK::Concepts::Unsigned;
|
2021-05-16 05:36:52 -04:00
|
|
|
using AK::Concepts::VoidFunction;
|