summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/NonnullOwnPtr.h4
-rw-r--r--AK/OwnPtr.h4
-rw-r--r--AK/RefCounted.h1
-rw-r--r--Libraries/LibWeb/HighResolutionTime/Performance.h2
4 files changed, 9 insertions, 2 deletions
diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h
index 30addf86b2..7bf5def3b5 100644
--- a/AK/NonnullOwnPtr.h
+++ b/AK/NonnullOwnPtr.h
@@ -52,7 +52,9 @@ public:
NonnullOwnPtr(AdoptTag, T& ptr)
: m_ptr(&ptr)
{
- static_assert(!is_ref_counted((const T*)nullptr), "Use RefPtr<> for RefCounted types");
+ static_assert(
+ requires { requires typename T::AllowOwnPtr()(); } || !requires(T obj) { requires !typename T::AllowOwnPtr()(); obj.ref(); obj.unref(); },
+ "Use NonnullRefPtr<> for RefCounted types");
}
NonnullOwnPtr(NonnullOwnPtr&& other)
: m_ptr(other.leak_ptr())
diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h
index 6b87526092..0f8a1b2967 100644
--- a/AK/OwnPtr.h
+++ b/AK/OwnPtr.h
@@ -38,7 +38,9 @@ public:
explicit OwnPtr(T* ptr)
: m_ptr(ptr)
{
- static_assert(!is_ref_counted((const T*)nullptr), "Use RefPtr<> for RefCounted types");
+ static_assert(
+ requires { requires typename T::AllowOwnPtr()(); } || !requires(T obj) { requires !typename T::AllowOwnPtr()(); obj.ref(); obj.unref(); },
+ "Use RefPtr<> for RefCounted types");
}
OwnPtr(OwnPtr&& other)
: m_ptr(other.leak_ptr())
diff --git a/AK/RefCounted.h b/AK/RefCounted.h
index d2b95915ae..86b6d76aab 100644
--- a/AK/RefCounted.h
+++ b/AK/RefCounted.h
@@ -65,6 +65,7 @@ class RefCountedBase {
public:
typedef unsigned int RefCountType;
+ using AllowOwnPtr = FalseType;
ALWAYS_INLINE void ref() const
{
diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.h b/Libraries/LibWeb/HighResolutionTime/Performance.h
index 3d3bad0c65..6cb39f014e 100644
--- a/Libraries/LibWeb/HighResolutionTime/Performance.h
+++ b/Libraries/LibWeb/HighResolutionTime/Performance.h
@@ -26,6 +26,7 @@
#pragma once
+#include <AK/StdLibExtras.h>
#include <LibCore/ElapsedTimer.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/EventTarget.h>
@@ -37,6 +38,7 @@ class Performance final
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::PerformanceWrapper;
+ using AllowOwnPtr = AK::TrueType;
explicit Performance(DOM::Window&);
~Performance();