NonnullRefPtr: Simplify copy constructors.

This commit is contained in:
Andreas Kling 2019-06-24 10:23:59 +02:00
parent 2dd54f062a
commit bad8ab697b
Notes: sideshowbarker 2024-07-19 13:29:47 +09:00

View file

@ -74,14 +74,16 @@ public:
}
RETURN_TYPESTATE(unconsumed)
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>
RETURN_TYPESTATE(unconsumed)
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()
{