1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

NonnullRefPtr: Simplify copy constructors.

This commit is contained in:
Andreas Kling 2019-06-24 10:23:59 +02:00
parent 2dd54f062a
commit bad8ab697b

View file

@ -74,14 +74,16 @@ public:
} }
RETURN_TYPESTATE(unconsumed) RETURN_TYPESTATE(unconsumed)
NonnullRefPtr(const NonnullRefPtr& other) NonnullRefPtr(const NonnullRefPtr& other)
: m_ptr(&const_cast<NonnullRefPtr&>(other).copy_ref().leak_ref()) : m_ptr(const_cast<T*>(other.ptr()))
{ {
m_ptr->ref();
} }
template<typename U> template<typename U>
RETURN_TYPESTATE(unconsumed) RETURN_TYPESTATE(unconsumed)
NonnullRefPtr(const NonnullRefPtr<U>& other) NonnullRefPtr(const NonnullRefPtr<U>& other)
: m_ptr(&const_cast<NonnullRefPtr<U>&>(other).copy_ref().leak_ref()) : m_ptr(const_cast<T*>(static_cast<const T*>((other.ptr()))))
{ {
m_ptr->ref();
} }
~NonnullRefPtr() ~NonnullRefPtr()
{ {