Introduce QT_NO_AS_CONST and mark QtBase free of it
Change-Id: I680086e767fe6d5c69eb7103b26150293c69b175 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
612c8e428e
commit
c72bf262ea
@ -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")
|
||||
|
@ -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)
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user