QFlags::testFlag: code tidies

If the condition Int(flag) != 0 is false, it means that flag == 0.
So just check i against 0, which is more in line with what testFlag
behavior is documented to do.

Change-Id: Ia75fa07eee65e67a769fda7c020bf17ada77e9a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2021-05-03 00:18:57 +02:00
parent 23780891a5
commit 81bb764e98

View File

@ -145,7 +145,7 @@ public:
constexpr inline bool operator!() const noexcept { return !i; }
constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); }
constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(0) ); }
constexpr inline QFlags &setFlag(Enum flag, bool on = true) noexcept
{
return on ? (*this |= flag) : (*this &= ~QFlags(flag));