aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-11-24 11:58:43 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-08 16:47:29 +0900
commit5ea115d6eb0b60dfd0c2be5fbe5e69615b133238 (patch)
treea4c454defbf9c483894b910178c086b3ffdc96f0 /lib
parented1f15151babee9ebc690ffa5c2593119540e8f0 (diff)
downloadlibquotient-5ea115d6eb0b60dfd0c2be5fbe5e69615b133238.tar.gz
libquotient-5ea115d6eb0b60dfd0c2be5fbe5e69615b133238.zip
Omittable: better editability; drop implicit cast to bool
Diffstat (limited to 'lib')
-rw-r--r--lib/util.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/util.h b/lib/util.h
index 1028e059..722a7e3d 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -108,15 +108,23 @@ namespace QMatrixClient
}
bool omitted() const { return _omitted; }
- const value_type& value() const { Q_ASSERT(!_omitted); return _value; }
- value_type& value() { Q_ASSERT(!_omitted); return _value; }
+ const value_type& value() const
+ {
+ Q_ASSERT(!_omitted);
+ return _value;
+ }
+ value_type& editValue()
+ {
+ _omitted = false;
+ return _value;
+ }
value_type&& release() { _omitted = true; return std::move(_value); }
- operator bool() const { return !omitted(); }
- const value_type* operator->() const { return &_value; }
- value_type* operator->() { return &_value; }
- const value_type& operator*() const { return _value; }
- value_type& operator*() { return _value; }
+ operator value_type&() & { return editValue(); }
+ const value_type* operator->() const & { return &value(); }
+ value_type* operator->() & { return &editValue(); }
+ const value_type& operator*() const & { return value(); }
+ value_type& operator*() & { return editValue(); }
private:
T _value;