From b90a516d80ae1b310ae57c06c70a4c7e59026ae0 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Fri, 17 Apr 2020 15:53:06 +0300 Subject: [PATCH] Update smart pointers to accommodate new changes. --- sqrat/sqrat/sqratUtil.h | 84 ++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/sqrat/sqrat/sqratUtil.h b/sqrat/sqrat/sqratUtil.h index 518ddee5..9ddfb285 100644 --- a/sqrat/sqrat/sqratUtil.h +++ b/sqrat/sqrat/sqratUtil.h @@ -203,7 +203,7 @@ struct SqDefaultDestructor; template > class SharedPtr; -template +template > class WeakPtr; /// @endcond @@ -703,7 +703,7 @@ class SharedPtr template friend class SharedPtr; - template + template friend class WeakPtr; typedef SqReferenceCounter Counter; @@ -815,7 +815,7 @@ public: /// \param copy SharedPtr to copy /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SharedPtr(const SharedPtr& copy) + SharedPtr(const SharedPtr& copy) : SharedPtr(copy.m_Ptr, copy.m_Ref) { } @@ -829,7 +829,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - SharedPtr(const SharedPtr& copy) + SharedPtr(const SharedPtr& copy) : SharedPtr(static_cast(copy.m_Ptr), copy.m_Ref) { } @@ -840,7 +840,7 @@ public: /// \param other SharedPtr to move /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SharedPtr(SharedPtr&& other) noexcept + SharedPtr(SharedPtr&& other) noexcept : m_Ptr(other.m_Ptr) , m_Ref(other.m_Ref) { @@ -857,7 +857,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - SharedPtr(SharedPtr&& other) noexcept + SharedPtr(SharedPtr&& other) noexcept : m_Ptr(static_cast(other.m_Ptr)) , m_Ref(other.m_Ref) { @@ -873,7 +873,7 @@ public: /// \tparam U Type of copy (usually doesnt need to be defined explicitly) /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SharedPtr(const WeakPtr& copy) + SharedPtr(const WeakPtr& copy) : SharedPtr(copy.m_Ptr, copy.m_Ref) { } @@ -887,7 +887,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - SharedPtr(const WeakPtr& copy) + SharedPtr(const WeakPtr& copy) : SharedPtr(static_cast(copy.m_Ptr), copy.m_Ref) { } @@ -909,7 +909,7 @@ public: /// \return The SharedPtr itself /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SharedPtr& operator=(const SharedPtr& copy) + SharedPtr& operator=(const SharedPtr& copy) { Assign(copy.m_Ptr, copy.m_Ref); @@ -927,7 +927,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - SharedPtr& operator=(const SharedPtr& copy) + SharedPtr& operator=(const SharedPtr& copy) { Assign(static_cast(copy.m_Ptr), copy.m_Ref); @@ -942,7 +942,7 @@ public: /// \return The SharedPtr itself /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SharedPtr& operator=(SharedPtr&& other) noexcept + SharedPtr& operator=(SharedPtr&& other) noexcept { if (m_Ptr != other.m_Ptr) { @@ -969,7 +969,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - SharedPtr& operator=(SharedPtr&& other) noexcept + SharedPtr& operator=(SharedPtr&& other) noexcept { if (m_Ptr != static_cast(other.m_Ptr)) { @@ -1060,7 +1060,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - bool operator ==(const SharedPtr& right) const + bool operator ==(const SharedPtr& right) const { return m_Ptr == right.m_Ptr; } @@ -1069,7 +1069,7 @@ public: /// Compares with another SharedPtr /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool operator ==(const SharedPtr& right) const + bool operator ==(const SharedPtr& right) const { return m_Ptr == right.m_Ptr; } @@ -1079,7 +1079,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - bool friend operator ==(const SharedPtr& left, const U* right) + bool friend operator ==(const SharedPtr& left, const U* right) { return left.m_Ptr == right; } @@ -1088,7 +1088,7 @@ public: /// Compares with another pointer /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool friend operator ==(const SharedPtr& left, const T* right) + bool friend operator ==(const SharedPtr& left, const T* right) { return left.m_Ptr == right; } @@ -1098,7 +1098,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - bool friend operator ==(const U* left, const SharedPtr& right) + bool friend operator ==(const U* left, const SharedPtr& right) { return left == right.m_Ptr; } @@ -1107,7 +1107,7 @@ public: /// Compares with another pointer /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool friend operator ==(const T* left, const SharedPtr& right) + bool friend operator ==(const T* left, const SharedPtr& right) { return left == right.m_Ptr; } @@ -1117,7 +1117,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - bool operator !=(const SharedPtr& right) const + bool operator !=(const SharedPtr& right) const { return m_Ptr != right.m_Ptr; } @@ -1126,7 +1126,7 @@ public: /// Compares with another SharedPtr /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool operator !=(const SharedPtr& right) const + bool operator !=(const SharedPtr& right) const { return m_Ptr != right.m_Ptr; } @@ -1136,7 +1136,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - bool friend operator !=(const SharedPtr& left, const U* right) + bool friend operator !=(const SharedPtr& left, const U* right) { return left.m_Ptr != right; } @@ -1145,7 +1145,7 @@ public: /// Compares with another pointer /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool friend operator !=(const SharedPtr& left, const T* right) + bool friend operator !=(const SharedPtr& left, const T* right) { return left.m_Ptr != right; } @@ -1155,7 +1155,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - bool friend operator !=(const U* left, const SharedPtr& right) + bool friend operator !=(const U* left, const SharedPtr& right) { return left != right.m_Ptr; } @@ -1164,7 +1164,7 @@ public: /// Compares with another pointer /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool friend operator !=(const T* left, const SharedPtr& right) + bool friend operator !=(const T* left, const SharedPtr& right) { return left != right.m_Ptr; } @@ -1224,10 +1224,10 @@ public: /// std::weak_ptr was not used because it is a C++11 feature. /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template +template class WeakPtr { - template + template friend class SharedPtr; typedef SqReferenceCounter Counter; @@ -1310,7 +1310,7 @@ public: /// \param copy WeakPtr to copy /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WeakPtr(const WeakPtr& copy) + WeakPtr(const WeakPtr& copy) { Initialize(copy.m_Ptr, copy.m_Ref); } @@ -1324,7 +1324,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - WeakPtr(const WeakPtr& copy) + WeakPtr(const WeakPtr& copy) { Initialize(static_cast(copy.m_Ptr), copy.m_Ref); } @@ -1335,7 +1335,7 @@ public: /// \param other WeakPtr to move /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WeakPtr(WeakPtr&& other) noexcept + WeakPtr(WeakPtr&& other) noexcept : m_Ptr(other.m_Ptr) , m_Ref(other.m_Ref) { @@ -1352,7 +1352,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - WeakPtr(WeakPtr&& other) noexcept + WeakPtr(WeakPtr&& other) noexcept : m_Ptr(static_cast(other.m_Ptr)) , m_Ref(other.m_Ref) { @@ -1366,7 +1366,7 @@ public: /// \param copy SharedPtr to copy /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WeakPtr(const SharedPtr& copy) + WeakPtr(const SharedPtr& copy) { Initialize(copy.m_Ptr, copy.m_Ref); } @@ -1380,7 +1380,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - WeakPtr(const SharedPtr& copy) + WeakPtr(const SharedPtr& copy) { Initialize(static_cast(copy.m_Ptr), copy.m_Ref); } @@ -1402,7 +1402,7 @@ public: /// \return The WeakPtr itself /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WeakPtr& operator=(const WeakPtr& copy) + WeakPtr& operator=(const WeakPtr& copy) { Assign(copy.m_Ptr, copy.m_Ref); @@ -1420,7 +1420,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - WeakPtr& operator=(const WeakPtr& copy) + WeakPtr& operator=(const WeakPtr& copy) { Assign(static_cast(copy.m_Ptr), copy.m_Ref); @@ -1435,7 +1435,7 @@ public: /// \return The WeakPtr itself /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WeakPtr& operator=(WeakPtr&& other) noexcept + WeakPtr& operator=(WeakPtr&& other) noexcept { if (m_Ptr != other.m_Ptr) { @@ -1462,7 +1462,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - WeakPtr& operator=(WeakPtr&& other) noexcept + WeakPtr& operator=(WeakPtr&& other) noexcept { if (m_Ptr != static_cast(other.m_Ptr)) { @@ -1486,7 +1486,7 @@ public: /// \return The WeakPtr itself /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WeakPtr& operator=(const SharedPtr& copy) + WeakPtr& operator=(const SharedPtr& copy) { Assign(copy.m_Ptr, copy.m_Ref); @@ -1504,7 +1504,7 @@ public: /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - WeakPtr& operator=(const SharedPtr& copy) + WeakPtr& operator=(const SharedPtr& copy) { Assign(static_cast(copy.m_Ptr), copy.m_Ref); @@ -1528,9 +1528,9 @@ public: /// \return A SharedPtr which shares ownership of the managed object /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SharedPtr Lock() const + SharedPtr Lock() const { - return SharedPtr(m_Ptr, m_Ref); + return SharedPtr(m_Ptr, m_Ref); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2272,8 +2272,8 @@ template struct remove_volatile template struct remove_cv {typedef typename remove_volatile::type>::type type;}; template struct is_pointer_helper {static constexpr bool value = false;}; template struct is_pointer_helper {static constexpr bool value = true;}; -template struct is_pointer_helper > {static constexpr bool value = true;}; -template struct is_pointer_helper > {static constexpr bool value = true;}; +template struct is_pointer_helper > {static constexpr bool value = true;}; +template struct is_pointer_helper > {static constexpr bool value = true;}; template struct is_pointer : is_pointer_helper::type> {}; template struct is_reference {static constexpr bool value = false;}; template struct is_reference {static constexpr bool value = true;};