Use the copy & swap trick to simplify some code in QSharedPointer

Change-Id: I5fa2fae19126bea60b9682ed7765681dd6da8c15
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Thiago Macieira 2012-05-23 19:46:39 +02:00 committed by Qt by Nokia
parent 086d6e74d2
commit 6daea46918

View File

@ -305,13 +305,14 @@ public:
{ if (d) ref(); }
inline QSharedPointer<T> &operator=(const QSharedPointer<T> &other)
{
internalCopy(other);
QSharedPointer copy(other);
swap(copy);
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
inline QSharedPointer<T> &operator=(QSharedPointer<T> &&other)
{
QSharedPointer<T>::internalSwap(other);
swap(other);
return *this;
}
#endif
@ -372,7 +373,7 @@ public:
}
#endif
inline void clear() { *this = QSharedPointer<T>(); }
inline void clear() { QSharedPointer copy; swap(copy); }
QWeakPointer<T> toWeakRef() const;