summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-08-22 11:44:01 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2022-08-25 16:53:47 +0200
commit9c706e25673ccbe9d154720ea3e659b27edea80d (patch)
treebe85690e1afdde65bf2169c992b190f73c22826c
parent8aefcd4756ad13dcb383e3ae09d0a17d4947fda2 (diff)
Extract header qswap.h from qglobal.h
And move qSwap() docs from qalgorithms.qdoc to qswap.qdoc. Task-number: QTBUG-99313 Change-Id: I2385d5162a8dbb2de51a0c0509eced77b6a17159 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/CMakeLists.txt1
-rw-r--r--src/corelib/global/qglobal.h36
-rw-r--r--src/corelib/global/qswap.h54
-rw-r--r--src/corelib/global/qswap.qdoc14
-rw-r--r--src/corelib/tools/qalgorithms.qdoc12
5 files changed, 70 insertions, 47 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index aed5fd973a..1bd01cd30c 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -73,6 +73,7 @@ qt_internal_add_module(Core
global/qoverload.h
global/qprocessordetection.h
global/qrandom.cpp global/qrandom.h global/qrandom_p.h
+ global/qswap.h
global/qsysinfo.h
global/qsystemdetection.h
global/qtclasshelpermacros.h
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 0ebbc34f49..09072b8b6d 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -136,41 +136,6 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
-QT_WARNING_PUSH
-// warning: noexcept-expression evaluates to 'false' because of a call to 'void swap(..., ...)'
-QT_WARNING_DISABLE_GCC("-Wnoexcept")
-
-namespace QtPrivate
-{
-namespace SwapExceptionTester { // insulate users from the "using std::swap" below
- using std::swap; // import std::swap
- template <typename T>
- void checkSwap(T &t)
- noexcept(noexcept(swap(t, t)));
- // declared, but not implemented (only to be used in unevaluated contexts (noexcept operator))
-}
-} // namespace QtPrivate
-
-// Documented in ../tools/qalgorithm.qdoc
-template <typename T>
-constexpr void qSwap(T &value1, T &value2)
- noexcept(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1)))
-{
- using std::swap;
- swap(value1, value2);
-}
-
-// pure compile-time micro-optimization for our own headers, so not documented:
-template <typename T>
-constexpr inline void qt_ptr_swap(T* &lhs, T* &rhs) noexcept
-{
- T *tmp = lhs;
- lhs = rhs;
- rhs = tmp;
-}
-
-QT_WARNING_POP
-
Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
Q_CORE_EXPORT void qFreeAligned(void *ptr);
@@ -219,6 +184,7 @@ QT_END_NAMESPACE
#include <QtCore/qminmax.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qoverload.h>
+#include <QtCore/qswap.h>
#include <QtCore/qtdeprecationmarkers.h>
#include <QtCore/qtranslation.h>
#include <QtCore/qtresource.h>
diff --git a/src/corelib/global/qswap.h b/src/corelib/global/qswap.h
new file mode 100644
index 0000000000..9ff6c7d9c5
--- /dev/null
+++ b/src/corelib/global/qswap.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QSWAP_H
+#define QSWAP_H
+
+#include <QtCore/qtconfigmacros.h>
+#include <QtCore/qcompilerdetection.h>
+
+#if 0
+#pragma qt_class(QtSwap)
+#pragma qt_sync_stop_processing
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QT_WARNING_PUSH
+// warning: noexcept-expression evaluates to 'false' because of a call to 'void swap(..., ...)'
+QT_WARNING_DISABLE_GCC("-Wnoexcept")
+
+namespace QtPrivate
+{
+namespace SwapExceptionTester { // insulate users from the "using std::swap" below
+ using std::swap; // import std::swap
+ template <typename T>
+ void checkSwap(T &t)
+ noexcept(noexcept(swap(t, t)));
+ // declared, but not implemented (only to be used in unevaluated contexts (noexcept operator))
+}
+} // namespace QtPrivate
+
+// Documented in ../tools/qalgorithm.qdoc
+template <typename T>
+constexpr void qSwap(T &value1, T &value2)
+ noexcept(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1)))
+{
+ using std::swap;
+ swap(value1, value2);
+}
+
+// pure compile-time micro-optimization for our own headers, so not documented:
+template <typename T>
+constexpr inline void qt_ptr_swap(T* &lhs, T* &rhs) noexcept
+{
+ T *tmp = lhs;
+ lhs = rhs;
+ rhs = tmp;
+}
+
+QT_WARNING_POP
+
+QT_END_NAMESPACE
+
+#endif // QSWAP_H
diff --git a/src/corelib/global/qswap.qdoc b/src/corelib/global/qswap.qdoc
new file mode 100644
index 0000000000..2d9d56b694
--- /dev/null
+++ b/src/corelib/global/qswap.qdoc
@@ -0,0 +1,14 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*! \fn template <typename T> void qSwap(T &var1, T &var2)
+ \relates <QtSwap>
+ \deprecated
+
+ Use \c std::swap instead.
+
+ Exchanges the values of variables \a var1 and \a var2.
+
+ Example:
+ \snippet code/doc_src_qalgorithms.cpp 0
+*/
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index 4a9c03a43c..5fe0b3e8c3 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -109,18 +109,6 @@
\sa {container classes}, <QtGlobal>
*/
-/*! \fn template <typename T> void qSwap(T &var1, T &var2)
- \relates <QtAlgorithms>
- \deprecated
-
- Use \c std::swap instead.
-
- Exchanges the values of variables \a var1 and \a var2.
-
- Example:
- \snippet code/doc_src_qalgorithms.cpp 0
-*/
-
/*!
\fn template <typename ForwardIterator> void qDeleteAll(ForwardIterator begin, ForwardIterator end)
\relates <QtAlgorithms>