From d2759e0e32c613b18123970ac15aa1f71949a5e7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 2 May 2021 01:32:03 +0200 Subject: 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 --- src/corelib/global/qflags.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/global/qflags.h') 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)); } -- cgit v1.2.3