aboutsummaryrefslogtreecommitdiff
path: root/lib/util.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-13 13:32:04 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-13 14:01:44 +0900
commitd5c07b98cd708d0bf4590e7fd249aa972b090461 (patch)
treed06a425956c895ce65580a65891ad930a4d6df99 /lib/util.h
parent7b6ba76954f88558a638f174c68a87207fe4788d (diff)
downloadlibquotient-d5c07b98cd708d0bf4590e7fd249aa972b090461.tar.gz
libquotient-d5c07b98cd708d0bf4590e7fd249aa972b090461.zip
Fix Omittables accidentally becoming non-omitted when compared with non-Omittable values
Diffstat (limited to 'lib/util.h')
-rw-r--r--lib/util.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/util.h b/lib/util.h
index 336248d3..77c2bfdb 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -107,6 +107,25 @@ namespace QMatrixClient
return *this;
}
+ bool operator==(const value_type& rhs) const
+ {
+ return !omitted() && value() == rhs;
+ }
+ friend bool operator==(const value_type& lhs,
+ const Omittable<value_type>& rhs)
+ {
+ return rhs == lhs;
+ }
+ bool operator!=(const value_type& rhs) const
+ {
+ return !operator==(rhs);
+ }
+ friend bool operator!=(const value_type& lhs,
+ const Omittable<value_type>& rhs)
+ {
+ return !(rhs == lhs);
+ }
+
bool omitted() const { return _omitted; }
const value_type& value() const
{
@@ -136,7 +155,7 @@ namespace QMatrixClient
}
value_type&& release() { _omitted = true; return std::move(_value); }
- operator value_type&() & { return editValue(); }
+ operator const value_type&() const & { return value(); }
const value_type* operator->() const & { return &value(); }
value_type* operator->() & { return &editValue(); }
const value_type& operator*() const & { return value(); }