diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 56772dea4c..fcb4bc245a 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -8,6 +8,8 @@ namespace AK { template class OwnPtr; +template +class RefPtr; template inline void ref_if_not_null(T* ptr) @@ -89,6 +91,13 @@ public: template NonnullRefPtr& operator=(const OwnPtr&) = delete; + template + NonnullRefPtr(const RefPtr&) = delete; + template + NonnullRefPtr& operator=(const RefPtr&) = delete; + NonnullRefPtr(const RefPtr&) = delete; + NonnullRefPtr& operator=(const RefPtr&) = delete; + NonnullRefPtr& operator=(const NonnullRefPtr& other) { if (m_ptr != other.m_ptr) { @@ -129,11 +138,11 @@ public: return *this; } - NonnullRefPtr& operator=(T& object) + NonnullRefPtr& operator=(const T& object) { if (m_ptr != &object) { deref_if_not_null(m_ptr); - m_ptr = &object; + m_ptr = const_cast(&object); m_ptr->ref(); } return *this;