diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-11-24 11:58:43 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-12-08 16:47:29 +0900 |
commit | 5ea115d6eb0b60dfd0c2be5fbe5e69615b133238 (patch) | |
tree | a4c454defbf9c483894b910178c086b3ffdc96f0 /lib | |
parent | ed1f15151babee9ebc690ffa5c2593119540e8f0 (diff) | |
download | libquotient-5ea115d6eb0b60dfd0c2be5fbe5e69615b133238.tar.gz libquotient-5ea115d6eb0b60dfd0c2be5fbe5e69615b133238.zip |
Omittable: better editability; drop implicit cast to bool
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.h | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -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; |