1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QTCORE_QSWAP_H |
5 | #define QTCORE_QSWAP_H |
6 | |
7 | #include <QtCore/qtconfigmacros.h> |
8 | |
9 | #include <type_traits> |
10 | #include <utility> |
11 | |
12 | #if 0 |
13 | #pragma qt_class(QtSwap) |
14 | #pragma qt_sync_stop_processing |
15 | #endif |
16 | |
17 | QT_BEGIN_NAMESPACE |
18 | |
19 | template <typename T> |
20 | constexpr void qSwap(T &value1, T &value2) |
21 | noexcept(std::is_nothrow_swappable_v<T>) |
22 | { |
23 | using std::swap; |
24 | swap(value1, value2); |
25 | } |
26 | |
27 | // pure compile-time micro-optimization for our own headers, so not documented: |
28 | template <typename T> |
29 | constexpr inline void qt_ptr_swap(T* &lhs, T* &rhs) noexcept |
30 | { |
31 | T *tmp = lhs; |
32 | lhs = rhs; |
33 | rhs = tmp; |
34 | } |
35 | |
36 | QT_END_NAMESPACE |
37 | |
38 | #endif // QTCORE_QSWAP_H |
39 | |