TPropertyRef: Make use of symmetrical comparison operators

Makes the interface significantly more flexible.
This commit is contained in:
Lioncash 2020-06-28 00:32:44 -04:00
parent a48d3202b6
commit d1939eea95
1 changed files with 19 additions and 2 deletions

View File

@ -58,15 +58,32 @@ public:
return Get(); return Get();
} }
bool operator==(IProperty* pProperty) const bool operator==(const IProperty* pProperty) const
{ {
return mpProperty == pProperty; 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(); 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 */ /** Convenience typedefs */