LibJS: Allow constructing a GCPtr from another GCPtr of convertible type

This commit is contained in:
Matthew Olsson 2023-02-26 16:07:20 -07:00 committed by Andreas Kling
commit 5094dcf615
Notes: sideshowbarker 2024-07-17 01:27:18 +09:00

View file

@ -100,6 +100,18 @@ public:
{
}
GCPtr(GCPtr<T> const& other)
: m_ptr(other.ptr())
{
}
template<typename U>
GCPtr(GCPtr<U> const& other)
requires(IsConvertible<U*, T*>)
: m_ptr(other.ptr())
{
}
GCPtr(NonnullGCPtr<T> const& other)
: m_ptr(other.ptr())
{
@ -117,7 +129,6 @@ public:
{
}
GCPtr(GCPtr const&) = default;
GCPtr& operator=(GCPtr const&) = default;
template<typename U>