diff options
-rw-r--r-- | .cmake.conf | 1 | ||||
-rw-r--r-- | src/corelib/global/qttypetraits.h | 4 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 4 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/.cmake.conf b/.cmake.conf index 4f4c0a2017..979edb2e37 100644 --- a/.cmake.conf +++ b/.cmake.conf @@ -5,6 +5,7 @@ # (directly by qtbase) we actually add the extra definitions if (NOT DEFINED QT_SUPERBUILD OR DEFINED QT_REPO_MODULE_VERSION) set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1") + list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1") endif() set(QT_REPO_MODULE_VERSION "6.5.0") diff --git a/src/corelib/global/qttypetraits.h b/src/corelib/global/qttypetraits.h index 1832a1a734..e8939e7d5f 100644 --- a/src/corelib/global/qttypetraits.h +++ b/src/corelib/global/qttypetraits.h @@ -23,6 +23,8 @@ constexpr std::underlying_type_t<Enum> qToUnderlying(Enum e) noexcept return static_cast<std::underlying_type_t<Enum>>(e); } +#ifndef QT_NO_AS_CONST + // this adds const to non-const objects (like std::as_const) template <typename T> constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; } @@ -30,6 +32,8 @@ constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; template <typename T> void qAsConst(const T &&) = delete; +#endif // QT_NO_AS_CONST + // like std::exchange template <typename T, typename U = T> constexpr T qExchange(T &t, U &&newValue) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 8d2e6aabc9..02fd2fdeea 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1790,7 +1790,7 @@ void QPdfEnginePrivate::writeDestsRoot() QHash<QString, int> destObjects; QByteArray xs, ys; - for (const DestInfo &destInfo : qAsConst(destCache)) { + for (const DestInfo &destInfo : std::as_const(destCache)) { int destObj = addXrefEntry(-1); xs.setNum(static_cast<double>(destInfo.coords.x()), 'f'); ys.setNum(static_cast<double>(destInfo.coords.y()), 'f'); @@ -1808,7 +1808,7 @@ void QPdfEnginePrivate::writeDestsRoot() xprintf(" "); printString(anchors.constLast()); xprintf("]\n/Names [\n"); - for (const QString &anchor : qAsConst(anchors)) { + for (const QString &anchor : std::as_const(anchors)) { printString(anchor); xprintf(" %d 0 R\n", destObjects[anchor]); } diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index cbc1a258de..ec3df1f03d 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -920,7 +920,7 @@ void tst_QSplitter::task187373_addAbstractScrollAreas_data() "QTreeView" }; - for (const auto &className : qAsConst(classNames)) { + for (const auto &className : std::as_const(classNames)) { QTest::newRow(qPrintable(className + " 1")) << className << false << true; QTest::newRow(qPrintable(className + " 2")) << className << true << false; QTest::newRow(qPrintable(className + " 3")) << className << true << true; |