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 /src/corelib/plugin | |
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 'src/corelib/plugin')
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 2 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary.cpp | 2 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/plugin/qpluginloader.cpp | 6 |
5 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 06015127d6..a9d6247697 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -132,7 +132,7 @@ Q_GLOBAL_STATIC(QFactoryLoaderGlobals, qt_factoryloader_global) QFactoryLoaderPrivate::~QFactoryLoaderPrivate() { - for (QLibraryPrivate *library : qAsConst(libraryList)) + for (QLibraryPrivate *library : std::as_const(libraryList)) library->release(); } diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 79725e258e..dc00763fd5 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -357,7 +357,7 @@ inline void QLibraryStore::cleanup() // dump all objects that remain if (lcDebugLibrary().isDebugEnabled()) { - for (QLibraryPrivate *lib : qAsConst(data->libraryMap)) { + for (QLibraryPrivate *lib : std::as_const(data->libraryMap)) { if (lib) qDebug(lcDebugLibrary) << "On QtCore unload," << lib->fileName << "was leaked, with" diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 7ad6e9e335..898d5a2f6c 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -164,7 +164,7 @@ bool QLibraryPrivate::load_sys() QStringList tmp; qSwap(tmp, list); list.reserve(tmp.size() * 2); - for (const QString &s : qAsConst(tmp)) { + for (const QString &s : std::as_const(tmp)) { QString modifiedPath = s; f(&modifiedPath); list.append(modifiedPath); diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index 741dd8cff9..c95118e554 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -59,7 +59,7 @@ bool QLibraryPrivate::load_sys() locker.unlock(); Handle hnd = nullptr; - for (const QString &attempt : qAsConst(attempts)) { + for (const QString &attempt : std::as_const(attempts)) { hnd = LoadLibrary(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(attempt).utf16())); // If we have a handle or the last error is something other than "unable diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index e86d4ccec8..599256783e 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -246,9 +246,9 @@ static QString locatePlugin(const QString& fileName) paths = QCoreApplication::libraryPaths(); } - for (const QString &path : qAsConst(paths)) { - for (const QString &prefix : qAsConst(prefixes)) { - for (const QString &suffix : qAsConst(suffixes)) { + for (const QString &path : std::as_const(paths)) { + for (const QString &prefix : std::as_const(prefixes)) { + for (const QString &suffix : std::as_const(suffixes)) { #ifdef Q_OS_ANDROID { QString pluginPath = basePath + prefix + baseName + suffix; |