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).
This commit is contained in:
Matthew Olsson 2023-02-25 10:43:27 -07:00 committed by Linus Groh
parent a9372de972
commit 17a528c49e
Notes: sideshowbarker 2024-07-17 05:21:12 +09:00

View file

@ -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))
{
}