diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-05-12 12:10:57 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-05-13 21:49:00 +0000 |
commit | bb72dc217d945b4b86054ef334ba229d94ec0ad3 (patch) | |
tree | 0915a9675c5f7b1106b6ea643bfb2545f7ae7948 | |
parent | 7cba2acd2cc4b68b5a4de2251ab555adb09bf7e8 (diff) |
QPointer: fix swap()
Make it noexcept and add an overload as a free function.
[ChangeLog][QtCore][QPointer] Added a free swap function.
Change-Id: I50744b9bae6a52db71b2da39e310619b3a0d6510
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
-rw-r--r-- | src/corelib/kernel/qpointer.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index b2b3cda4ab..016658ee60 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -77,7 +77,7 @@ public: ~QPointer(); #endif - inline void swap(QPointer &other) { wp.swap(other.wp); } + inline void swap(QPointer &other) noexcept { wp.swap(other.wp); } inline QPointer<T> &operator=(T* p) { wp.assign(static_cast<QObjectType*>(p)); return *this; } @@ -146,6 +146,10 @@ qPointerFromVariant(const QVariant &variant) return QPointer<T>(qobject_cast<T*>(QtSharedPointer::weakPointerFromVariant_internal(variant).data())); } +template <class T> +inline void swap(QPointer<T> &p1, QPointer<T> &p2) noexcept +{ p1.swap(p2); } + QT_END_NAMESPACE #endif // QT_NO_QOBJECT |