Index: webrtc/base/optional.h |
diff --git a/webrtc/base/optional.h b/webrtc/base/optional.h |
index 728ed9e7378c07ce4b2c0c89edecfc497c14c4f7..ec33470f26754a868ce56cef35a189dfc6f8ab69 100644 |
--- a/webrtc/base/optional.h |
+++ b/webrtc/base/optional.h |
@@ -234,16 +234,28 @@ class Optional final { |
} |
// Equality tests. Two Optionals are equal if they contain equivalent values, |
- // or |
- // if they're both empty. |
+ // or if they're both empty. |
friend bool operator==(const Optional& m1, const Optional& m2) { |
return m1.has_value_ && m2.has_value_ ? m1.value_ == m2.value_ |
: m1.has_value_ == m2.has_value_; |
} |
+ friend bool operator==(const Optional& opt, const T& value) { |
+ return opt.has_value_ && opt.value_ == value; |
+ } |
+ friend bool operator==(const T& value, const Optional& opt) { |
+ return opt.has_value_ && value == opt.value_; |
+ } |
+ |
friend bool operator!=(const Optional& m1, const Optional& m2) { |
return m1.has_value_ && m2.has_value_ ? m1.value_ != m2.value_ |
: m1.has_value_ != m2.has_value_; |
} |
+ friend bool operator!=(const Optional& opt, const T& value) { |
+ return !opt.has_value_ || opt.value_ != value; |
+ } |
+ friend bool operator!=(const T& value, const Optional& opt) { |
+ return !opt.has_value_ || value != opt.value_; |
+ } |
private: |
// Tell sanitizers that value_ shouldn't be touched. |