summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2019-05-10 20:53:47 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2019-05-11 20:23:10 +0000
commita0c4b6f34546bdd22167a76a0540d37e9a37c0cf (patch)
tree91019489b65a4843a52ed87b30e3ad8d91cc42d6 /src/corelib/tools
parent1a0df46b9868cca653c1d343e8ec3ffc009c5e33 (diff)
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>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index c219d310dc..80543f1983 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -386,7 +386,7 @@ public:
inline QSharedPointer<T> &operator=(const QWeakPointer<X> &other)
{ internalSet(other.d, other.value); return *this; }
- inline void swap(QSharedPointer &other)
+ inline void swap(QSharedPointer &other) noexcept
{ this->internalSwap(other); }
inline void reset() { clear(); }
@@ -880,18 +880,12 @@ Q_INLINE_TEMPLATE QWeakPointer<T> QSharedPointer<T>::toWeakRef() const
}
template <class T>
-inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2)
-{
- p1.swap(p2);
-}
+inline void swap(QSharedPointer<T> &p1, QSharedPointer<T> &p2) noexcept
+{ p1.swap(p2); }
-QT_END_NAMESPACE
-namespace std {
- template <class T>
- inline void swap(QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p2)
- { p1.swap(p2); }
-}
-QT_BEGIN_NAMESPACE
+template <class T>
+inline void swap(QWeakPointer<T> &p1, QWeakPointer<T> &p2) noexcept
+{ p1.swap(p2); }
namespace QtSharedPointer {
// helper functions: