summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-06-25 07:33:15 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-03 01:56:31 +0430
commit3162c9e21447b3d994f7486fc8d2ee9b681140b4 (patch)
tree8c6cc4801633719e3296d43709794ede3561ef6e
parentb97a00d4b1324e474f8ff37269773f93c2af2161 (diff)
downloadserenity-3162c9e21447b3d994f7486fc8d2ee9b681140b4.zip
AK: Make `(Nonnull)OwnPtr` work with abstract classes
Clang produced a compile error at this requires statement if `T` was an abstract class.
-rw-r--r--AK/NonnullOwnPtr.h2
-rw-r--r--AK/OwnPtr.h3
2 files changed, 2 insertions, 3 deletions
diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h
index 1553a9c562..58a3f3a7bf 100644
--- a/AK/NonnullOwnPtr.h
+++ b/AK/NonnullOwnPtr.h
@@ -33,7 +33,7 @@ public:
: m_ptr(&ptr)
{
static_assert(
- requires { requires typename T::AllowOwnPtr()(); } || !requires(T obj) { requires !typename T::AllowOwnPtr()(); obj.ref(); obj.unref(); },
+ requires { requires typename T::AllowOwnPtr()(); } || !requires { requires !typename T::AllowOwnPtr()(); declval<T>().ref(); declval<T>().unref(); },
"Use NonnullRefPtr<> for RefCounted types");
}
NonnullOwnPtr(NonnullOwnPtr&& other)
diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h
index 3eb42d1c36..0fba019ddf 100644
--- a/AK/OwnPtr.h
+++ b/AK/OwnPtr.h
@@ -184,8 +184,7 @@ protected:
: m_ptr(ptr)
{
static_assert(
- requires { requires typename T::AllowOwnPtr()(); } || !requires(T obj) { requires !typename T::AllowOwnPtr()(); obj.ref(); obj.unref(); },
- "Use RefPtr<> for RefCounted types");
+ requires { requires typename T::AllowOwnPtr()(); } || !requires { requires !typename T::AllowOwnPtr()(); declval<T>().ref(); declval<T>().unref(); }, "Use RefPtr<> for RefCounted types");
}
private: