From d1939eea9588a9f158a4e3cb52dc35c02058e1a3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 00:32:44 -0400 Subject: [PATCH] TPropertyRef: Make use of symmetrical comparison operators Makes the interface significantly more flexible. --- .../Resource/Script/Property/TPropertyRef.h | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Core/Resource/Script/Property/TPropertyRef.h b/src/Core/Resource/Script/Property/TPropertyRef.h index 80f8c6bb..7ed182ad 100644 --- a/src/Core/Resource/Script/Property/TPropertyRef.h +++ b/src/Core/Resource/Script/Property/TPropertyRef.h @@ -58,15 +58,32 @@ public: return Get(); } - bool operator==(IProperty* pProperty) const + bool operator==(const IProperty* pProperty) const { return mpProperty == pProperty; } + bool operator!=(const IProperty* pProperty) const + { + return !operator==(pProperty); + } - friend bool operator==(IProperty* pLeft, const TPropertyRef& kRight) + friend bool operator==(const IProperty* pLeft, const TPropertyRef& kRight) { return pLeft == kRight.Property(); } + friend bool operator!=(const IProperty* pLeft, const TPropertyRef& kRight) + { + return !operator==(pLeft, kRight); + } + + friend bool operator==(const TPropertyRef& left, const IProperty* right) + { + return left.Property() == right; + } + friend bool operator!=(const TPropertyRef& left, const IProperty* right) + { + return !operator==(left, right); + } }; /** Convenience typedefs */