From 17a528c49e250ffd6c64d680e9a28fe112483852 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sat, 25 Feb 2023 10:43:27 -0700 Subject: [PATCH] LibJS: Temporarily disambiguate const-ness of GCPtr constructors Without this change, using {Nonnull,}GCPtr would complain that there are multiple constructors which resolve to the same type (T& and T const&). This removes that disambiguation and allows us to slowly fix all of the constness issues surrounding GCPtrs. This change will not be necessary in the future as we will be able to remove all of the const qualifiers from the Ptr classes (they'll be in the template type instead). --- Userland/Libraries/LibJS/Heap/GCPtr.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Heap/GCPtr.h b/Userland/Libraries/LibJS/Heap/GCPtr.h index 92c1096607..ed7790ab02 100644 --- a/Userland/Libraries/LibJS/Heap/GCPtr.h +++ b/Userland/Libraries/LibJS/Heap/GCPtr.h @@ -24,6 +24,7 @@ public: } NonnullGCPtr(T const& ptr) + requires(!IsConst) : m_ptr(&const_cast(ptr)) { } @@ -37,7 +38,7 @@ public: template NonnullGCPtr(U const& ptr) - requires(IsConvertible) + requires(IsConvertible && !IsConst) : m_ptr(&const_cast(static_cast(ptr))) { } @@ -96,6 +97,7 @@ public: } GCPtr(T const& ptr) + requires(!IsConst) : m_ptr(&const_cast(ptr)) { } @@ -106,6 +108,7 @@ public: } GCPtr(T const* ptr) + requires(!IsConst) : m_ptr(const_cast(ptr)) { }