Index: Source/wtf/Assertions.h |
diff --git a/Source/wtf/Assertions.h b/Source/wtf/Assertions.h |
index 73fc317c6c5c2880275b8cc3bc2aa777acae5fc9..ca91dd2bcf039897f93153a6b7e186ac617cf999 100644 |
--- a/Source/wtf/Assertions.h |
+++ b/Source/wtf/Assertions.h |
@@ -362,6 +362,24 @@ static inline void UNREACHABLE_FOR_PLATFORM() |
#define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED() |
#endif |
+/* DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES */ |
+ |
+// Allow equality comparisons of Objects by reference or pointer, interchangeably. |
+#define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ |
+ inline bool operator==(const thisType& a, const thisType& b) { return &a == &b; } \ |
+ inline bool operator==(const thisType& a, const thisType* b) { return &a == b; } \ |
+ inline bool operator==(const thisType* a, const thisType& b) { return a == &b; } \ |
+ inline bool operator!=(const thisType& a, const thisType& b) { return !(a == b); } \ |
+ inline bool operator!=(const thisType& a, const thisType* b) { return !(a == b); } \ |
+ inline bool operator!=(const thisType* a, const thisType& b) { return !(a == b); } |
+ |
+#define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(thisType) \ |
+ DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ |
+ inline bool operator==(const PassRefPtr<thisType>& a, const thisType& b) { return a.get() == &b; } \ |
+ inline bool operator==(const thisType& a, const PassRefPtr<thisType>& b) { return &a == b.get(); } \ |
+ inline bool operator!=(const PassRefPtr<thisType>& a, const thisType& b) { return !(a == b); } \ |
+ inline bool operator!=(const thisType& a, const PassRefPtr<thisType>& b) { return !(a == b); } |
+ |
/* DEFINE_TYPE_CASTS */ |
#define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, pointerPredicate, referencePredicate) \ |