diff --git a/luna/include/luna/SharedPtr.h b/luna/include/luna/SharedPtr.h index 08c09931..4cf1bcff 100644 --- a/luna/include/luna/SharedPtr.h +++ b/luna/include/luna/SharedPtr.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include #include @@ -54,6 +53,24 @@ template class SharedPtr } } + SharedPtr& operator=(const SharedPtr& other) + { + if (&other == this) return *this; + + if (m_ref_count && m_ref_count->unref()) + { + delete m_ref_count; + delete m_ptr; + } + + m_ptr = other.m_ptr; + m_ref_count = other.m_ref_count; + + m_ref_count->ref(); + + return *this; + } + T* ptr() const { return m_ptr;