diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 53ab7aeccd..a055ccc681 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -18,6 +18,9 @@ namespace AK { +template +class OwnPtr; + template inline void ref_if_not_null(T* ptr) { @@ -93,6 +96,11 @@ public: #endif } + template + NonnullRefPtr(const OwnPtr&) = delete; + template + NonnullRefPtr& operator=(const OwnPtr&) = delete; + NonnullRefPtr& operator=(const NonnullRefPtr& other) { if (m_ptr != other.m_ptr) { diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index a10cc5bdb0..ba93fd63b3 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -7,6 +7,13 @@ namespace AK { +template +class RefPtr; +template +class NonnullRefPtr; +template +class WeakPtr; + template class OwnPtr { public: @@ -36,6 +43,19 @@ public: #endif } + template + OwnPtr(const RefPtr&) = delete; + template + OwnPtr(const NonnullRefPtr&) = delete; + template + OwnPtr(const WeakPtr&) = delete; + template + OwnPtr& operator=(const RefPtr&) = delete; + template + OwnPtr& operator=(const NonnullRefPtr&) = delete; + template + OwnPtr& operator=(const WeakPtr&) = delete; + OwnPtr& operator=(OwnPtr&& other) { if (this != &other) { diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 349fb1de1c..99ebca89b9 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -6,6 +6,9 @@ namespace AK { +template +class OwnPtr; + template class RefPtr { public: @@ -86,6 +89,11 @@ public: } RefPtr(std::nullptr_t) {} + template + RefPtr(const OwnPtr&) = delete; + template + RefPtr& operator=(const OwnPtr&) = delete; + RefPtr& operator=(RefPtr&& other) { if (this != &other) {