mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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:
parent
a9372de972
commit
17a528c49e
Notes:
sideshowbarker
2024-07-17 05:21:12 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/17a528c49e Pull-request: https://github.com/SerenityOS/serenity/pull/17620 Issue: https://github.com/SerenityOS/serenity/issues/16988 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/linusg
1 changed files with 4 additions and 1 deletions
|
@ -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))
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue