diff --git a/src/util/parented_ptr.h b/src/util/parented_ptr.h index 4b98e8d4bec..e54bdb7f958 100644 --- a/src/util/parented_ptr.h +++ b/src/util/parented_ptr.h @@ -58,22 +58,6 @@ class parented_ptr { return m_pObject; } - bool operator== (const parented_ptr& other) const { - return m_pObject == other.m_pObject; - } - - bool operator== (const T* other) const { - return m_pObject == other; - } - - bool operator!= (const parented_ptr& other) const { - return m_pObject != other.m_pObject; - } - - bool operator!= (const T* other) const { - return m_pObject != other; - } - operator bool() const { return m_pObject != nullptr; } @@ -104,6 +88,37 @@ inline parented_ptr make_parented(Args&&... args) { return parented_ptr(new T(std::forward(args)...)); } +// Comparison operator definitions +template +inline bool operator== (const T* lhs, const parented_ptr& rhs) { + return lhs == rhs.get(); +} + +template +inline bool operator== (const parented_ptr& lhs, const U* rhs) { + return lhs.get() == rhs; +} + +template +inline bool operator== (const parented_ptr& lhs, const parented_ptr& rhs) const { + return lhs.get() == rhs.get(); +} + +template +inline bool operator!= (const T* lhs, const parented_ptr& rhs) { + return !(lhs == rhs.get()); +} + +template +inline bool operator!= (const parented_ptr& lhs, const U* rhs) { + return !(lhs.get() == rhs); +} + +template +inline bool operator!= (const parented_ptr& lhs, const parented_ptr& rhs) const { + return !(lhs.get() == rhs.get()); +} + } // namespace #endif // UTIL_PARENTED_PTR_H