diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 11:08:21 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-11 23:17:18 +0200 |
commit | aa37e67ef7f5ff22da0ef95fb5221bc1fff9b3ca (patch) | |
tree | be5e1a9733987aed8602eb47618cd1673a594570 /tests/auto/corelib/serialization/qcborvalue | |
parent | fd2685c2f0a219c091e028a98ba6cdd154986fec (diff) |
Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.
Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto/corelib/serialization/qcborvalue')
-rw-r--r-- | tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index d8dfc5e99a..82e2309680 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -785,7 +785,7 @@ void tst_QCborValue::arrayInitializerList() // range for int i = 0; - for (const QCborValue v : qAsConst(a)) { + for (const QCborValue v : std::as_const(a)) { QVERIFY(!v.isInvalid()); QCOMPARE(v.isUndefined(), i == 5); // 6th element is Undefined ++i; @@ -885,7 +885,7 @@ void tst_QCborValue::mapSimpleInitializerList() // range for int i = 0; - for (auto pair : qAsConst(m)) { + for (auto pair : std::as_const(m)) { QVERIFY(!pair.first.isUndefined()); QVERIFY(!pair.second.isUndefined()); ++i; @@ -1294,16 +1294,16 @@ void tst_QCborValue::arrayValueRefLargeKey() a[LargeKey + 1] = 123; QCborValue v(a); - QCOMPARE(qAsConst(v)[LargeKey], QCborValue()); - QCOMPARE(qAsConst(v)[LargeKey + 1], 123); + QCOMPARE(std::as_const(v)[LargeKey], QCborValue()); + QCOMPARE(std::as_const(v)[LargeKey + 1], 123); QCOMPARE(v[LargeKey], QCborValue()); QCOMPARE(v[LargeKey + 1], 123); QCOMPARE(v.type(), QCborValue::Array); QCborArray outer = { QCborValue(a) }; QCborValueRef ref = outer[0]; - QCOMPARE(qAsConst(ref)[LargeKey], QCborValue()); - QCOMPARE(qAsConst(ref)[LargeKey + 1], 123); + QCOMPARE(std::as_const(ref)[LargeKey], QCborValue()); + QCOMPARE(std::as_const(ref)[LargeKey + 1], 123); QCOMPARE(ref[LargeKey], QCborValue()); QCOMPARE(ref[LargeKey + 1], 123); QCOMPARE(ref.type(), QCborValue::Array); @@ -1714,7 +1714,7 @@ void tst_QCborValue::arrayNested() QCborArray a1 = { 42, 47 }; QCborArray a2 = { QCborValue(a1) }; QCOMPARE(a2.size(), 1); - const QCborValue &first = qAsConst(a2).first(); + const QCborValue &first = std::as_const(a2).first(); QVERIFY(first.isArray()); QCOMPARE(first.toArray(wrongArray).size(), 2); QCOMPARE(first.toArray(wrongArray).first(), 42); @@ -1735,7 +1735,7 @@ void tst_QCborValue::arrayNested() QCborArray a1; a1 = { QCborValue(a1) }; // insert it into itself QCOMPARE(a1.size(), 1); - const QCborValue &first = qAsConst(a1).first(); + const QCborValue &first = std::as_const(a1).first(); QVERIFY(first.isArray()); QCOMPARE(first, QCborArray()); QCOMPARE(first.toArray(wrongArray), QCborArray()); @@ -1752,7 +1752,7 @@ void tst_QCborValue::arrayNested() QCborArray a1; a1.append(a1); // insert into itself QCOMPARE(a1.size(), 1); - const QCborValue &first = qAsConst(a1).first(); + const QCborValue &first = std::as_const(a1).first(); QVERIFY(first.isArray()); QCOMPARE(first, QCborArray()); QCOMPARE(first.toArray(), QCborArray()); @@ -2694,9 +2694,9 @@ template <typename ValueRef> static void cborValueRef_template() QCOMPARE(ref.toArray().isEmpty(), v.toArray().isEmpty()); QCOMPARE(ref.toMap().isEmpty(), v.toMap().isEmpty()); - QCOMPARE(ref[0], qAsConst(v)[0]); - QCOMPARE(ref[QLatin1String("other")], qAsConst(v)[QLatin1String("other")]); - QCOMPARE(ref[QString("other")], qAsConst(v)[QString("other")]); + QCOMPARE(ref[0], std::as_const(v)[0]); + QCOMPARE(ref[QLatin1String("other")], std::as_const(v)[QLatin1String("other")]); + QCOMPARE(ref[QString("other")], std::as_const(v)[QString("other")]); if (qIsNaN(v.toDouble())) QCOMPARE(qIsNaN(ref.toVariant().toDouble()), qIsNaN(v.toVariant().toDouble())); |