-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Sona Kurazyan
committed
Aug 25, 2022
1 parent
8aefcd4
commit 9c706e2
Showing
5 changed files
with
70 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters