From 453a5387cb6c88bb083f20d2e23d662e6f29e64f Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 4 Aug 2023 10:20:45 +0300 Subject: [PATCH] BAN: UniqPtr can now be constructed from other convertible UniqPtr --- BAN/include/BAN/UniqPtr.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/BAN/include/BAN/UniqPtr.h b/BAN/include/BAN/UniqPtr.h index c22a1b7ca9..96dbd39938 100644 --- a/BAN/include/BAN/UniqPtr.h +++ b/BAN/include/BAN/UniqPtr.h @@ -14,7 +14,8 @@ namespace BAN public: UniqPtr() = default; - UniqPtr(UniqPtr&& other) + template + UniqPtr(UniqPtr&& other) { m_pointer = other.m_pointer; other.m_pointer = nullptr; @@ -42,8 +43,10 @@ namespace BAN return uniq; } - UniqPtr& operator=(UniqPtr&& other) + template + UniqPtr& operator=(UniqPtr&& other) { + clear(); m_pointer = other.m_pointer; other.m_pointer = nullptr; return *this; @@ -87,6 +90,9 @@ namespace BAN private: T* m_pointer = nullptr; + + template + friend class UniqPtr; }; } \ No newline at end of file