diff --git a/AK/Buffered.h b/AK/Buffered.h index ab4c7e2752..5eec15d544 100644 --- a/AK/Buffered.h +++ b/AK/Buffered.h @@ -17,11 +17,11 @@ namespace AK { // FIXME: Implement Buffered for DuplexStream. -template +template class Buffered; template -class Buffered>::Type> final : public InputStream { +requires(IsBaseOf) class Buffered final : public InputStream { AK_MAKE_NONCOPYABLE(Buffered); public: @@ -119,7 +119,7 @@ private: }; template -class Buffered>::Type> final : public OutputStream { +requires(IsBaseOf) class Buffered : public OutputStream { AK_MAKE_NONCOPYABLE(Buffered); public: @@ -192,7 +192,6 @@ private: u8 m_buffer[Size]; size_t m_buffered { 0 }; }; - } using AK::Buffered; diff --git a/AK/Format.cpp b/AK/Format.cpp index 63e9ff8689..ecd0948d31 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -692,8 +692,8 @@ ErrorOr Formatter::vformat(FormatBuilder& builder, StringVie return {}; } -template -ErrorOr Formatter>::Type>::format(FormatBuilder& builder, T value) +template +ErrorOr Formatter::format(FormatBuilder& builder, T value) { if (m_mode == Mode::Character) { // FIXME: We just support ASCII for now, in the future maybe unicode? diff --git a/AK/Format.h b/AK/Format.h index 2034980594..83971c1474 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -307,8 +307,8 @@ struct StandardFormatter { void parse(TypeErasedFormatParams&, FormatParser&); }; -template -struct Formatter>::Type> : StandardFormatter { +template +struct Formatter : StandardFormatter { Formatter() = default; explicit Formatter(StandardFormatter formatter) : StandardFormatter(move(formatter)) diff --git a/AK/StdLibExtraDetails.h b/AK/StdLibExtraDetails.h index 1b91e33751..3357363ea2 100644 --- a/AK/StdLibExtraDetails.h +++ b/AK/StdLibExtraDetails.h @@ -10,15 +10,6 @@ namespace AK::Detail { -template -struct EnableIf { -}; - -template -struct EnableIf { - using Type = T; -}; - template struct IntegralConstant { static constexpr T value = v; @@ -591,7 +582,6 @@ using AK::Detail::Conditional; using AK::Detail::CopyConst; using AK::Detail::declval; using AK::Detail::DependentFalse; -using AK::Detail::EnableIf; using AK::Detail::FalseType; using AK::Detail::IdentityType; using AK::Detail::IndexSequence; diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index cfd3da2d49..a7e3346abe 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -22,27 +22,27 @@ class [[nodiscard]] WeakPtr { public: WeakPtr() = default; - template>::Type* = nullptr> - WeakPtr(const WeakPtr& other) + template + WeakPtr(const WeakPtr& other) requires(IsBaseOf) : m_link(other.m_link) { } - template>::Type* = nullptr> - WeakPtr(WeakPtr&& other) + template + WeakPtr(WeakPtr&& other) requires(IsBaseOf) : m_link(other.take_link()) { } - template>::Type* = nullptr> - WeakPtr& operator=(WeakPtr&& other) + template + WeakPtr& operator=(WeakPtr&& other) requires(IsBaseOf) { m_link = other.take_link(); return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const WeakPtr& other) + template + WeakPtr& operator=(const WeakPtr& other) requires(IsBaseOf) { if ((const void*)this != (const void*)&other) m_link = other.m_link; @@ -55,41 +55,41 @@ public: return *this; } - template>::Type* = nullptr> - WeakPtr(const U& object) + template + WeakPtr(const U& object) requires(IsBaseOf) : m_link(object.template make_weak_ptr().take_link()) { } - template>::Type* = nullptr> - WeakPtr(const U* object) + template + WeakPtr(const U* object) requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); } - template>::Type* = nullptr> - WeakPtr(RefPtr const& object) + template + WeakPtr(RefPtr const& object) requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); } - template>::Type* = nullptr> - WeakPtr(NonnullRefPtr const& object) + template + WeakPtr(NonnullRefPtr const& object) requires(IsBaseOf) { m_link = object->template make_weak_ptr().take_link(); } - template>::Type* = nullptr> - WeakPtr& operator=(const U& object) + template + WeakPtr& operator=(const U& object) requires(IsBaseOf) { m_link = object.template make_weak_ptr().take_link(); return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const U* object) + template + WeakPtr& operator=(const U* object) requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); @@ -98,8 +98,8 @@ public: return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const RefPtr& object) + template + WeakPtr& operator=(const RefPtr& object) requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); @@ -108,8 +108,8 @@ public: return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const NonnullRefPtr& object) + template + WeakPtr& operator=(const NonnullRefPtr& object) requires(IsBaseOf) { m_link = object->template make_weak_ptr().take_link(); return *this; diff --git a/AK/Weakable.h b/AK/Weakable.h index 0aad3cb436..122fb6ddfa 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -32,8 +32,9 @@ class WeakLink : public RefCounted { friend class WeakPtr; public: - template, typename EnableIf>::Type* = nullptr> + template> RefPtr strong_ref() const + requires(IsBaseOf) { RefPtr ref; diff --git a/Kernel/Library/ThreadSafeRefPtr.h b/Kernel/Library/ThreadSafeRefPtr.h index b8bda74833..7bb5312dfe 100644 --- a/Kernel/Library/ThreadSafeRefPtr.h +++ b/Kernel/Library/ThreadSafeRefPtr.h @@ -361,16 +361,17 @@ public: ALWAYS_INLINE bool is_null() const { return PtrTraits::is_null(m_bits.load(AK::MemoryOrder::memory_order_relaxed)); } - template && !IsNullPointer>::Type* = nullptr> + template typename PtrTraits::NullType null_value() const + requires(IsSame && !IsNullPointer) { // make sure we are holding a null value FlatPtr bits = m_bits.load(AK::MemoryOrder::memory_order_relaxed); VERIFY(PtrTraits::is_null(bits)); return PtrTraits::to_null_value(bits); } - template && !IsNullPointer>::Type* = nullptr> - void set_null_value(typename PtrTraits::NullType value) + template + void set_null_value(typename PtrTraits::NullType value) requires(IsSame && !IsNullPointer) { // make sure that new null value would be interpreted as a null value FlatPtr bits = PtrTraits::from_null_value(value); diff --git a/Kernel/Library/ThreadSafeWeakPtr.h b/Kernel/Library/ThreadSafeWeakPtr.h index c0642ff079..ba8cda9d1e 100644 --- a/Kernel/Library/ThreadSafeWeakPtr.h +++ b/Kernel/Library/ThreadSafeWeakPtr.h @@ -18,27 +18,27 @@ class [[nodiscard]] WeakPtr { public: WeakPtr() = default; - template>::Type* = nullptr> - WeakPtr(const WeakPtr& other) + template + WeakPtr(const WeakPtr& other) requires(IsBaseOf) : m_link(other.m_link) { } - template>::Type* = nullptr> - WeakPtr(WeakPtr&& other) + template + WeakPtr(WeakPtr&& other) requires(IsBaseOf) : m_link(other.take_link()) { } - template>::Type* = nullptr> - WeakPtr& operator=(WeakPtr&& other) + template + WeakPtr& operator=(WeakPtr&& other) requires(IsBaseOf) { m_link = other.take_link(); return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const WeakPtr& other) + template + WeakPtr& operator=(const WeakPtr& other) requires(IsBaseOf) { if ((const void*)this != (const void*)&other) m_link = other.m_link; @@ -51,21 +51,21 @@ public: return *this; } - template>::Type* = nullptr> - WeakPtr(const U& object) + template + WeakPtr(const U& object) requires(IsBaseOf) : m_link(object.template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link()) { } - template>::Type* = nullptr> - WeakPtr(const U* object) + template + WeakPtr(const U* object) requires(IsBaseOf) { if (object) m_link = object->template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link(); } - template>::Type* = nullptr> - WeakPtr(const RefPtr& object) + template + WeakPtr(const RefPtr& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -73,8 +73,8 @@ public: }); } - template>::Type* = nullptr> - WeakPtr(const NonnullRefPtr& object) + template + WeakPtr(const NonnullRefPtr& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -82,15 +82,15 @@ public: }); } - template>::Type* = nullptr> - WeakPtr& operator=(const U& object) + template + WeakPtr& operator=(const U& object) requires(IsBaseOf) { m_link = object.template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link(); return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const U* object) + template + WeakPtr& operator=(const U* object) requires(IsBaseOf) { if (object) m_link = object->template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link(); @@ -99,8 +99,8 @@ public: return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const RefPtr& object) + template + WeakPtr& operator=(const RefPtr& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -111,8 +111,8 @@ public: return *this; } - template>::Type* = nullptr> - WeakPtr& operator=(const NonnullRefPtr& object) + template + WeakPtr& operator=(const NonnullRefPtr& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) diff --git a/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h b/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h index a2ca483f51..dab4ca3d1b 100644 --- a/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h +++ b/Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h @@ -11,13 +11,12 @@ namespace Gfx { -template::Type> -class SpatialGaussianBlurFilter : public GenericConvolutionFilter { +template +requires(N % 2 == 1) class SpatialGaussianBlurFilter : public GenericConvolutionFilter { public: SpatialGaussianBlurFilter() = default; virtual ~SpatialGaussianBlurFilter() = default; virtual const char* class_name() const override { return "SpatialGaussianBlurFilter"; } }; - }