diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-12 14:14:02 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-14 15:52:58 +0200 |
commit | 6f0df02d002356625f10683ef84da7685d92a2c4 (patch) | |
tree | 46713209af459ebda534c3404f48c5f5c80ba3f8 /tests/auto/corelib/tools | |
parent | 44cce1a2ea9dadd8b2de93f40de34269dda703c0 (diff) |
Replace Qt CONSTEXPR defines with constexpr
Both normal and relaxed constexpr are required by our new minimum of
C++17.
Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
5 files changed, 17 insertions, 17 deletions
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 964c68c9e9..44e6bef6f0 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -1046,25 +1046,25 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const #endif // QT_DEPRECATED_SINCE(5, 2) // alternative implementation of qPopulationCount for comparison: -static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = { +static constexpr const uint bitsSetInNibble[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, }; static_assert(sizeof bitsSetInNibble / sizeof *bitsSetInNibble == 16); -static Q_DECL_CONSTEXPR uint bitsSetInByte(quint8 byte) +static constexpr uint bitsSetInByte(quint8 byte) { return bitsSetInNibble[byte & 0xF] + bitsSetInNibble[byte >> 4]; } -static Q_DECL_CONSTEXPR uint bitsSetInShort(quint16 word) +static constexpr uint bitsSetInShort(quint16 word) { return bitsSetInByte(word & 0xFF) + bitsSetInByte(word >> 8); } -static Q_DECL_CONSTEXPR uint bitsSetInInt(quint32 word) +static constexpr uint bitsSetInInt(quint32 word) { return bitsSetInShort(word & 0xFFFF) + bitsSetInShort(word >> 16); } -static Q_DECL_CONSTEXPR uint bitsSetInInt64(quint64 word) +static constexpr uint bitsSetInInt64(quint64 word) { return bitsSetInInt(word & 0xFFFFFFFF) + bitsSetInInt(word >> 32); } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 8b78b34992..52464ffc15 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -1149,7 +1149,7 @@ void tst_QArrayData::literals() struct LiteralType { int value; - Q_DECL_CONSTEXPR LiteralType(int v = 0) : value(v) {} + constexpr LiteralType(int v = 0) : value(v) {} }; { @@ -1226,17 +1226,17 @@ struct CompilerHasCxx11ImplicitMoves struct DetectConstructor { - Q_DECL_CONSTEXPR DetectConstructor() + constexpr DetectConstructor() : constructor(DefaultConstructor) { } - Q_DECL_CONSTEXPR DetectConstructor(const DetectConstructor &) + constexpr DetectConstructor(const DetectConstructor &) : constructor(CopyConstructor) { } - Q_DECL_CONSTEXPR DetectConstructor(DetectConstructor &&) + constexpr DetectConstructor(DetectConstructor &&) : constructor(MoveConstructor) { } diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index c5ba53ad57..f0af24a96b 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -3094,7 +3094,7 @@ void tst_QList::fromReadOnlyData() const { struct LiteralType { int value; - Q_DECL_CONSTEXPR LiteralType(int v = 0) : value(v) {} + constexpr LiteralType(int v = 0) : value(v) {} }; const LiteralType literal[] = {LiteralType(0), LiteralType(1), LiteralType(2)}; diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp index 464477d5d1..70caa055b6 100644 --- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -174,15 +174,15 @@ void tst_QPair::structuredBindings() void tst_QPair::testConstexpr() { - Q_CONSTEXPR QPair<int, double> pID = qMakePair(0, 0.0); + constexpr QPair<int, double> pID = qMakePair(0, 0.0); Q_UNUSED(pID); - Q_CONSTEXPR QPair<double, double> pDD = qMakePair(0.0, 0.0); - Q_CONSTEXPR QPair<double, double> pDD2 = qMakePair(0, 0.0); // involes (rvalue) conversion ctor - Q_CONSTEXPR bool equal = pDD2 == pDD; + constexpr QPair<double, double> pDD = qMakePair(0.0, 0.0); + constexpr QPair<double, double> pDD2 = qMakePair(0, 0.0); // involes (rvalue) conversion ctor + constexpr bool equal = pDD2 == pDD; QVERIFY(equal); - Q_CONSTEXPR QPair<QSize, int> pSI = qMakePair(QSize(4, 5), 6); + constexpr QPair<QSize, int> pSI = qMakePair(QSize(4, 5), 6); Q_UNUSED(pSI); } diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 8e92ed44f4..95c2c2bb70 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -2943,8 +2943,8 @@ struct Overloaded { return {}; } - static const Q_CONSTEXPR uint base1Called = sizeof(std::array<int, 1>); - static const Q_CONSTEXPR uint base2Called = sizeof(std::array<int, 2>); + static const constexpr uint base1Called = sizeof(std::array<int, 1>); + static const constexpr uint base2Called = sizeof(std::array<int, 2>); void test() { |