summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qswap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global/qswap.h')
-rw-r--r--src/corelib/global/qswap.h30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/corelib/global/qswap.h b/src/corelib/global/qswap.h
index 9ff6c7d9c5..3d533c8a95 100644
--- a/src/corelib/global/qswap.h
+++ b/src/corelib/global/qswap.h
@@ -1,11 +1,13 @@
// 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
+#ifndef QTCORE_QSWAP_H
+#define QTCORE_QSWAP_H
#include <QtCore/qtconfigmacros.h>
-#include <QtCore/qcompilerdetection.h>
+
+#include <type_traits>
+#include <utility>
#if 0
#pragma qt_class(QtSwap)
@@ -14,25 +16,9 @@
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)))
+ noexcept(std::is_nothrow_swappable_v<T>)
{
using std::swap;
swap(value1, value2);
@@ -47,8 +33,6 @@ constexpr inline void qt_ptr_swap(T* &lhs, T* &rhs) noexcept
rhs = tmp;
}
-QT_WARNING_POP
-
QT_END_NAMESPACE
-#endif // QSWAP_H
+#endif // QTCORE_QSWAP_H