From: <ps...@us...> - 2010-03-09 18:58:39
|
Revision: 1818 http://znc.svn.sourceforge.net/znc/?rev=1818&view=rev Author: psychon Date: 2010-03-09 18:58:31 +0000 (Tue, 09 Mar 2010) Log Message: ----------- 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. Modified Paths: -------------- trunk/Utils.h Modified: trunk/Utils.h =================================================================== --- trunk/Utils.h 2010-03-09 16:47:07 UTC (rev 1817) +++ trunk/Utils.h 2010-03-09 18:58:31 UTC (rev 1818) @@ -413,8 +413,6 @@ // 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 @@ 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |