Use Q_DECL_RELAXED_CONSTEXPR in QFlags
Change-Id: I91073f4bb71e554402fc13cbd0e9ba5b5b95bce0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
053e8c41d7
commit
6700fb0bf0
@ -117,13 +117,13 @@ public:
|
||||
: i(initializer_list_helper(flags.begin(), flags.end())) {}
|
||||
#endif
|
||||
|
||||
inline QFlags &operator&=(int mask) { i &= mask; return *this; }
|
||||
inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
|
||||
inline QFlags &operator&=(Enum mask) { i &= Int(mask); return *this; }
|
||||
inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
|
||||
inline QFlags &operator|=(Enum f) { i |= Int(f); return *this; }
|
||||
inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
|
||||
inline QFlags &operator^=(Enum f) { i ^= Int(f); return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) { i &= mask; return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) { i &= Int(mask); return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum f) { i |= Int(f); return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum f) { i ^= Int(f); return *this; }
|
||||
|
||||
Q_DECL_CONSTEXPR inline operator Int() const { return i; }
|
||||
|
||||
|
@ -3,3 +3,4 @@ TARGET = tst_qflags
|
||||
QT = core testlib
|
||||
SOURCES = tst_qflags.cpp
|
||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
||||
contains(QT_CONFIG, c++11): CONFIG += c++11 c++14
|
||||
|
@ -94,6 +94,16 @@ void tst_QFlags::testFlagMultiBits() const
|
||||
|
||||
template <unsigned int N, typename T> bool verifyConstExpr(T n) { return n == N; }
|
||||
|
||||
Q_DECL_RELAXED_CONSTEXPR Qt::MouseButtons testRelaxedConstExpr()
|
||||
{
|
||||
Qt::MouseButtons value;
|
||||
value = Qt::LeftButton | Qt::RightButton;
|
||||
value |= Qt::MiddleButton;
|
||||
value &= ~Qt::LeftButton;
|
||||
value ^= Qt::RightButton;
|
||||
return value;
|
||||
}
|
||||
|
||||
void tst_QFlags::constExpr()
|
||||
{
|
||||
#ifdef Q_COMPILER_CONSTEXPR
|
||||
@ -115,6 +125,10 @@ void tst_QFlags::constExpr()
|
||||
QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) | 0xff>(0xff));
|
||||
|
||||
QVERIFY(!verifyConstExpr<Qt::RightButton>(!Qt::MouseButtons(Qt::LeftButton)));
|
||||
|
||||
#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
|
||||
QVERIFY(verifyConstExpr<testRelaxedConstExpr()>(Qt::MiddleButton));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user