From 7b6ba76954f88558a638f174c68a87207fe4788d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 13 Jan 2019 11:49:21 +0900 Subject: util.h: check for fallthrough attribute instead of C++ version --- lib/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/util.h') diff --git a/lib/util.h b/lib/util.h index 9c9a37ba..336248d3 100644 --- a/lib/util.h +++ b/lib/util.h @@ -27,7 +27,7 @@ #include #include -#if __cplusplus >= 201703L +#if __has_cpp_attribute(fallthrough) #define FALLTHROUGH [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) #define FALLTHROUGH [[clang::fallthrough]] -- cgit v1.2.3 From d5c07b98cd708d0bf4590e7fd249aa972b090461 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 13 Jan 2019 13:32:04 +0900 Subject: Fix Omittables accidentally becoming non-omitted when compared with non-Omittable values --- lib/util.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/util.h') 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& rhs) + { + return rhs == lhs; + } + bool operator!=(const value_type& rhs) const + { + return !operator==(rhs); + } + friend bool operator!=(const value_type& lhs, + const Omittable& 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(); } -- cgit v1.2.3