mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:52:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			88 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Forward.h>
 | |
| #include <AK/IterationDecision.h>
 | |
| #include <AK/StdLibExtras.h>
 | |
| 
 | |
| namespace AK::Concepts {
 | |
| 
 | |
| template<typename T>
 | |
| concept Integral = IsIntegral<T>;
 | |
| 
 | |
| template<typename T>
 | |
| concept FloatingPoint = IsFloatingPoint<T>;
 | |
| 
 | |
| template<typename T>
 | |
| concept Arithmetic = IsArithmetic<T>;
 | |
| 
 | |
| template<typename T>
 | |
| concept Signed = IsSigned<T>;
 | |
| 
 | |
| template<typename T>
 | |
| concept Unsigned = IsUnsigned<T>;
 | |
| 
 | |
| template<typename T>
 | |
| concept Enum = IsEnum<T>;
 | |
| 
 | |
| template<typename T, typename U>
 | |
| concept SameAs = IsSame<T, U>;
 | |
| 
 | |
| template<typename T>
 | |
| concept AnyString = Detail::IsConstructible<StringView, T>;
 | |
| 
 | |
| template<typename T, typename U>
 | |
| concept HashCompatible = IsHashCompatible<Detail::Decay<T>, Detail::Decay<U>>;
 | |
| 
 | |
| // FIXME: remove once Clang formats these properly.
 | |
| // clang-format off
 | |
| 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>;
 | |
| };
 | |
| 
 | |
| template<typename T, typename EndT>
 | |
| concept IteratorPairWith = requires(T it, EndT end)
 | |
| {
 | |
|     *it;
 | |
|     { it != end } -> SameAs<bool>;
 | |
|     ++it;
 | |
| };
 | |
| 
 | |
| template<typename T>
 | |
| concept IterableContainer = requires
 | |
| {
 | |
|     { declval<T>().begin() } -> IteratorPairWith<decltype(declval<T>().end())>;
 | |
| };
 | |
| 
 | |
| // clang-format on
 | |
| }
 | |
| 
 | |
| using AK::Concepts::Arithmetic;
 | |
| 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::Signed;
 | |
| using AK::Concepts::Unsigned;
 | |
| using AK::Concepts::VoidFunction;
 | 
