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>
Giuseppe D'Angelo 2019-05-12 12:10:57 +02:00
parent 7cba2acd2c
commit bb72dc217d
1 changed files with 5 additions and 1 deletions

View File

@ -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