diff -r 56cd8111b7f7 -r 41300fa6a67c src/corelib/tools/qscopedpointer.h --- a/src/corelib/tools/qscopedpointer.h Tue Jan 26 12:42:25 2010 +0200 +++ b/src/corelib/tools/qscopedpointer.h Tue Feb 02 00:43:10 2010 +0200 @@ -113,16 +113,6 @@ return d; } - inline bool operator==(const QScopedPointer &other) const - { - return d == other.d; - } - - inline bool operator!=(const QScopedPointer &other) const - { - return d != other.d; - } - inline bool operator!() const { return !d; @@ -181,6 +171,18 @@ }; template +inline bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) +{ + return lhs.data() == rhs.data(); +} + +template +inline bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) +{ + return lhs.data() != rhs.data(); +} + +template Q_INLINE_TEMPLATE void qSwap(QScopedPointer &p1, QScopedPointer &p2) { p1.swap(p2); } @@ -203,104 +205,10 @@ return this->d[i]; } - inline bool operator==(const QScopedArrayPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedArrayPointer &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QScopedArrayPointer) }; -/* Internal helper class - exposes the data through data_ptr (legacy from QShared). - Required for some internal Qt classes, do not use otherwise. */ -template > -class QCustomScopedPointer : public QScopedPointer -{ -public: - explicit inline QCustomScopedPointer(T *p = 0) - : QScopedPointer(p) - { - } - - inline T *&data_ptr() - { - return this->d; - } - - inline bool operator==(const QCustomScopedPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QCustomScopedPointer &other) const - { - return this->d != other.d; - } - -private: - Q_DISABLE_COPY(QCustomScopedPointer) -}; - -/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */ -template -class QScopedPointerSharedDeleter -{ -public: - static inline void cleanup(T *d) - { - if (d && !d->ref.deref()) - delete d; - } -}; - -/* Internal. - This class is basically a scoped pointer pointing to a ref-counted object - */ -template -class QScopedSharedPointer : public QCustomScopedPointer > -{ -public: - explicit inline QScopedSharedPointer(T *p = 0) - : QCustomScopedPointer >(p) - { - } - - inline void detach() - { - qAtomicDetach(this->d); - } - - inline void assign(T *other) - { - if (this->d == other) - return; - if (other) - other->ref.ref(); - T *oldD = this->d; - this->d = other; - QScopedPointerSharedDeleter::cleanup(oldD); - } - - inline bool operator==(const QScopedSharedPointer &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedSharedPointer &other) const - { - return this->d != other.d; - } - -private: - Q_DISABLE_COPY(QScopedSharedPointer) -}; - QT_END_NAMESPACE QT_END_HEADER