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
This commit is contained in:
psychon
2010-03-09 18:58:31 +00:00
parent 2ca15364d4
commit 9036f5de74
+9 -2
View File
@@ -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<T>& 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<typename T>
bool operator ==(T* lhs, const CSmartPtr<T>& rhs) { return (lhs == rhs.GetPtr()); }
template<typename T>
bool operator ==(const CSmartPtr<T>& lhs, T* rhs) { return (lhs.GetPtr() == rhs); }
template<typename T>
bool operator ==(const CSmartPtr<T>& lhs, const CSmartPtr<T>& rhs) { return (lhs.GetPtr() == rhs.GetPtr()); }
#endif // !_UTILS_H