Преглед изворни кода

LibJS: Temporarily disambiguate const-ness of GCPtr constructors

Without this change, using {Nonnull,}GCPtr<T const> 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).
Matthew Olsson пре 2 година
родитељ
комит
17a528c49e
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      Userland/Libraries/LibJS/Heap/GCPtr.h

+ 4 - 1
Userland/Libraries/LibJS/Heap/GCPtr.h

@@ -24,6 +24,7 @@ public:
     }
 
     NonnullGCPtr(T const& ptr)
+    requires(!IsConst<T>)
         : m_ptr(&const_cast<T&>(ptr))
     {
     }
@@ -37,7 +38,7 @@ public:
 
     template<typename U>
     NonnullGCPtr(U const& ptr)
-    requires(IsConvertible<U*, T*>)
+    requires(IsConvertible<U*, T*> && !IsConst<T>)
         : m_ptr(&const_cast<T&>(static_cast<T const&>(ptr)))
     {
     }
@@ -96,6 +97,7 @@ public:
     }
 
     GCPtr(T const& ptr)
+    requires(!IsConst<T>)
         : m_ptr(&const_cast<T&>(ptr))
     {
     }
@@ -106,6 +108,7 @@ public:
     }
 
     GCPtr(T const* ptr)
+    requires(!IsConst<T>)
         : m_ptr(const_cast<T*>(ptr))
     {
     }