diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-05-02 01:32:03 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-05-11 13:22:44 +0200 |
commit | d2759e0e32c613b18123970ac15aa1f71949a5e7 (patch) | |
tree | 07e5123f8e3f44ca3d74cd7122ab0b9837d6ba79 /src/corelib/global/qflags.h | |
parent | 53049d60277e0168a6c9f514674f26f9c25df84b (diff) |
QFlags: add operator& / &= overloads taking a QFlags object
It makes no sense to offer the "type-unsafe" operators taking a plain
int, and not offer the ones taking a QFlags object. Using these
operators has actually always worked by going through a conversion to
int, but we're going to limit that possibility in the future.
[ChangeLog][QtCore][QFlags] The operator& and operator&= now accept
a QFlags object.
Change-Id: Iee0845640014d35b646787e8bdb77854f180a9ef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qflags.h')
-rw-r--r-- | src/corelib/global/qflags.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 8fb6cb09a3..0b7f3f7d6c 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -117,6 +117,7 @@ public: constexpr inline QFlags &operator&=(int mask) noexcept { i &= mask; return *this; } constexpr inline QFlags &operator&=(uint mask) noexcept { i &= mask; return *this; } + constexpr inline QFlags &operator&=(QFlags mask) noexcept { i &= mask.i; return *this; } constexpr inline QFlags &operator&=(Enum mask) noexcept { i &= Int(mask); return *this; } constexpr inline QFlags &operator|=(QFlags other) noexcept { i |= other.i; return *this; } constexpr inline QFlags &operator|=(Enum other) noexcept { i |= Int(other); return *this; } @@ -131,6 +132,7 @@ public: constexpr inline QFlags operator^(Enum other) const noexcept { return QFlags(QFlag(i ^ Int(other))); } constexpr inline QFlags operator&(int mask) const noexcept { return QFlags(QFlag(i & mask)); } constexpr inline QFlags operator&(uint mask) const noexcept { return QFlags(QFlag(i & mask)); } + constexpr inline QFlags operator&(QFlags other) const noexcept { return QFlags(QFlag(i & other.i)); } constexpr inline QFlags operator&(Enum other) const noexcept { return QFlags(QFlag(i & Int(other))); } constexpr inline QFlags operator~() const noexcept { return QFlags(QFlag(~i)); } |