mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
AK: Make C++ concepts support mandatory for compilers
The latest GCC and Clang versions both support this, so we can freely use these in our code.
This commit is contained in:
parent
4c0c4f3102
commit
985adcca38
|
@ -11,8 +11,6 @@
|
|||
|
||||
namespace AK::Concepts {
|
||||
|
||||
#if defined(__cpp_concepts) && !defined(__COVERITY__)
|
||||
|
||||
template<typename T>
|
||||
concept Integral = IsIntegral<T>;
|
||||
|
||||
|
@ -31,13 +29,15 @@ concept Unsigned = IsUnsigned<T>;
|
|||
template<typename T, typename U>
|
||||
concept SameAs = IsSame<T, 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>;
|
||||
-> SameAs<void>;
|
||||
};
|
||||
|
||||
template<typename Func, typename... Args>
|
||||
|
@ -46,15 +46,11 @@ concept IteratorFunction = requires(Func func, Args... args)
|
|||
{
|
||||
func(args...)
|
||||
}
|
||||
->SameAs<IterationDecision>;
|
||||
-> SameAs<IterationDecision>;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
#if defined(__cpp_concepts) && !defined(__COVERITY__)
|
||||
|
||||
using AK::Concepts::Arithmetic;
|
||||
using AK::Concepts::FloatingPoint;
|
||||
using AK::Concepts::Integral;
|
||||
|
@ -62,5 +58,3 @@ using AK::Concepts::IteratorFunction;
|
|||
using AK::Concepts::Signed;
|
||||
using AK::Concepts::Unsigned;
|
||||
using AK::Concepts::VoidFunction;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,16 +12,10 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
// HACK: This is just here to make syntax highlighting work in Qt Creator.
|
||||
// Once it supports C++20 concepts, we can remove this.
|
||||
#if defined(__cpp_concepts) && !defined(__COVERITY__)
|
||||
template<typename T>
|
||||
concept PointerTypeName = IsPointer<T>;
|
||||
template<PointerTypeName T>
|
||||
#else
|
||||
template<typename T, typename EnableIf<IsPointer<T>, int>::Type = 0>
|
||||
#endif
|
||||
|
||||
template<PointerTypeName T>
|
||||
class Userspace {
|
||||
public:
|
||||
Userspace() = default;
|
||||
|
|
Loading…
Reference in a new issue