diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-12-08 22:39:38 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-12-08 22:39:38 +0900 |
commit | 4a252aa465c7a36268e8014674800e6d98a449e9 (patch) | |
tree | c56544f8d96e6ef60adec7d774e8dd603b0d0c90 /lib | |
parent | 9272d21ce6e5439444794e6da58e08421e8973db (diff) | |
download | libquotient-4a252aa465c7a36268e8014674800e6d98a449e9.tar.gz libquotient-4a252aa465c7a36268e8014674800e6d98a449e9.zip |
Omittable<>::merge<>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -118,6 +118,22 @@ namespace QMatrixClient _omitted = false; return _value; } + /// Merge the value from another Omittable + /// \return true if \p other is not omitted and the value of + /// the current Omittable was different (or omitted); + /// in other words, if the current Omittable has changed; + /// false otherwise + template <typename T1> + auto merge(const Omittable<T1>& other) + -> std::enable_if_t<std::is_convertible<T1, T>::value, bool> + { + if (other.omitted() || + (!_omitted && _value == other.value())) + return false; + _omitted = false; + _value = other.value(); + return true; + } value_type&& release() { _omitted = true; return std::move(_value); } operator value_type&() & { return editValue(); } |