2020-08-03 18:14:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-03 18:14:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-05-16 09:36:52 +00:00
|
|
|
#include <AK/IterationDecision.h>
|
2020-08-03 18:14:37 +00:00
|
|
|
#include <AK/StdLibExtras.h>
|
|
|
|
|
|
|
|
namespace AK::Concepts {
|
|
|
|
|
2020-08-16 22:11:05 +00:00
|
|
|
#if defined(__cpp_concepts) && !defined(__COVERITY__)
|
|
|
|
|
2020-08-03 18:14:37 +00:00
|
|
|
template<typename T>
|
2021-04-10 13:59:06 +00:00
|
|
|
concept Integral = IsIntegral<T>;
|
2020-08-03 18:14:37 +00:00
|
|
|
|
|
|
|
template<typename T>
|
2021-04-10 13:59:06 +00:00
|
|
|
concept FloatingPoint = IsFloatingPoint<T>;
|
2020-08-03 18:14:37 +00:00
|
|
|
|
2021-03-19 21:23:48 +00:00
|
|
|
template<typename T>
|
2021-04-10 13:59:06 +00:00
|
|
|
concept Arithmetic = IsArithmetic<T>;
|
2021-03-19 21:23:48 +00:00
|
|
|
|
2021-03-27 21:20:15 +00:00
|
|
|
template<typename T>
|
2021-04-10 13:59:06 +00:00
|
|
|
concept Signed = IsSigned<T>;
|
2021-03-27 21:20:15 +00:00
|
|
|
|
|
|
|
template<typename T>
|
2021-04-10 13:59:06 +00:00
|
|
|
concept Unsigned = IsUnsigned<T>;
|
2021-03-27 21:20:15 +00:00
|
|
|
|
2021-05-16 09:36:52 +00:00
|
|
|
template<typename T, typename U>
|
|
|
|
concept SameAs = IsSame<T, U>;
|
|
|
|
|
|
|
|
template<typename Func, typename... Args>
|
|
|
|
concept VoidFunction = requires(Func func, Args... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
func(args...)
|
|
|
|
}
|
|
|
|
->SameAs<void>;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Func, typename... Args>
|
|
|
|
concept IteratorFunction = requires(Func func, Args... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
func(args...)
|
|
|
|
}
|
|
|
|
->SameAs<IterationDecision>;
|
|
|
|
};
|
|
|
|
|
2020-08-16 22:11:05 +00:00
|
|
|
#endif
|
|
|
|
|
2020-08-03 18:14:37 +00:00
|
|
|
}
|
2020-12-05 22:25:19 +00:00
|
|
|
|
|
|
|
#if defined(__cpp_concepts) && !defined(__COVERITY__)
|
|
|
|
|
2021-03-27 21:24:50 +00:00
|
|
|
using AK::Concepts::Arithmetic;
|
|
|
|
using AK::Concepts::FloatingPoint;
|
|
|
|
using AK::Concepts::Integral;
|
2021-05-16 09:36:52 +00:00
|
|
|
using AK::Concepts::IteratorFunction;
|
2021-03-27 21:20:15 +00:00
|
|
|
using AK::Concepts::Signed;
|
|
|
|
using AK::Concepts::Unsigned;
|
2021-05-16 09:36:52 +00:00
|
|
|
using AK::Concepts::VoidFunction;
|
2020-12-05 22:25:19 +00:00
|
|
|
|
|
|
|
#endif
|