QSharedPointer/QWeakPointer: fix swap()

Do not specialize std::swap, just add swap in Qt's namespace.
Also add swap() for QWeakPointer, and sprinkle noexcept.

Change-Id: Ifb06c214f1865d42f3f2cddf5f980aede6bde185
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2019-05-10 20:53:47 +02:00
parent 1a0df46b98
commit a0c4b6f345

View File

@ -386,7 +386,7 @@ public:
inline QSharedPointer<T> &operator=(const QWeakPointer<X> &other) inline QSharedPointer<T> &operator=(const QWeakPointer<X> &other)
{ internalSet(other.d, other.value); return *this; } { internalSet(other.d, other.value); return *this; }
inline void swap(QSharedPointer &other) inline void swap(QSharedPointer &other) noexcept
{ this->internalSwap(other); } { this->internalSwap(other); }
inline void reset() { clear(); } inline void reset() { clear(); }
@ -880,18 +880,12 @@ Q_INLINE_TEMPLATE QWeakPointer<T> QSharedPointer<T>::toWeakRef() const
} }
template <class T> template <class T>
inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2) inline void swap(QSharedPointer<T> &p1, QSharedPointer<T> &p2) noexcept
{ { p1.swap(p2); }
p1.swap(p2);
}
QT_END_NAMESPACE template <class T>
namespace std { inline void swap(QWeakPointer<T> &p1, QWeakPointer<T> &p2) noexcept
template <class T> { p1.swap(p2); }
inline void swap(QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p2)
{ p1.swap(p2); }
}
QT_BEGIN_NAMESPACE
namespace QtSharedPointer { namespace QtSharedPointer {
// helper functions: // helper functions: