From 5094dcf615d56e03be458a80b191232819aeaae4 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sun, 26 Feb 2023 16:07:20 -0700 Subject: [PATCH] LibJS: Allow constructing a GCPtr from another GCPtr of convertible type --- Userland/Libraries/LibJS/Heap/GCPtr.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Heap/GCPtr.h b/Userland/Libraries/LibJS/Heap/GCPtr.h index 398a31cb99..3ab7e54994 100644 --- a/Userland/Libraries/LibJS/Heap/GCPtr.h +++ b/Userland/Libraries/LibJS/Heap/GCPtr.h @@ -100,6 +100,18 @@ public: { } + GCPtr(GCPtr const& other) + : m_ptr(other.ptr()) + { + } + + template + GCPtr(GCPtr const& other) + requires(IsConvertible) + : m_ptr(other.ptr()) + { + } + GCPtr(NonnullGCPtr const& other) : m_ptr(other.ptr()) { @@ -117,7 +129,6 @@ public: { } - GCPtr(GCPtr const&) = default; GCPtr& operator=(GCPtr const&) = default; template