From 9036f5de74b4b1ff244b56f94fb6555afc736d6a Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 9 Mar 2010 18:58:31 +0000 Subject: [PATCH] Fix CSmartPtr's operator== to actually work The old code only worked when the CSmartPtr instance was at the left side of the comparison and comparing two CSmartPtr directly resulted in a compiler error. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1818 726aef4b-f618-498e-8847-2d620e286838 --- Utils.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Utils.h b/Utils.h index b31121af..440e8d5d 100644 --- a/Utils.h +++ b/Utils.h @@ -413,8 +413,6 @@ public: // Overloaded operators T& operator *() const { assert(m_pType); return *m_pType; } T* operator ->() const { assert(m_pType); return m_pType; } - bool operator ==(T* rhs) const { return (m_pType == rhs); } - bool operator ==(const CSmartPtr& rhs) const { return (m_pType == *rhs); } /** * @brief Attach() to a raw pointer @@ -508,5 +506,14 @@ private: unsigned int* m_puCount; //!< Counter of how many CSmartPtr's are referencing the same raw pointer }; +template +bool operator ==(T* lhs, const CSmartPtr& rhs) { return (lhs == rhs.GetPtr()); } + +template +bool operator ==(const CSmartPtr& lhs, T* rhs) { return (lhs.GetPtr() == rhs); } + +template +bool operator ==(const CSmartPtr& lhs, const CSmartPtr& rhs) { return (lhs.GetPtr() == rhs.GetPtr()); } + #endif // !_UTILS_H