summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-11-06 15:09:39 (GMT)
committerMarius Storm-Olsen <marius.storm-olsen@nokia.com>2009-11-10 09:13:18 (GMT)
commitd5db58127b16f3c2508975661ee7328f569b9518 (patch)
treec043003941c6fbd58d714458f1c4d04cfd1ab12e /src/corelib
parent45c197899b7444230c7eefbb6f208eb237b07ed2 (diff)
downloadQt-d5db58127b16f3c2508975661ee7328f569b9518.zip
Qt-d5db58127b16f3c2508975661ee7328f569b9518.tar.gz
Qt-d5db58127b16f3c2508975661ee7328f569b9518.tar.bz2
Make QScopedPointer::operator== and != non-member
Non-member operator allows implicit conversions on both arguments. A single operator is enough to support QScopedArrayPointer, QCustomScopedPointer and QScopedSharedPointer since equality semantics don't change and the deleter is managed in the base class. Reviewed-by: Marius Storm-Olsen
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qscopedpointer.h52
1 files changed, 12 insertions, 40 deletions
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 7cbdb6c..b433723 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -113,16 +113,6 @@ public:
return d;
}
- inline bool operator==(const QScopedPointer<T, Cleanup> &other) const
- {
- return d == other.d;
- }
-
- inline bool operator!=(const QScopedPointer<T, Cleanup> &other) const
- {
- return d != other.d;
- }
-
inline bool operator!() const
{
return !d;
@@ -181,6 +171,18 @@ private:
};
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+{
+ return lhs.data() == rhs.data();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+{
+ return lhs.data() != rhs.data();
+}
+
+template <class T, class Cleanup>
Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2)
{ p1.swap(p2); }
@@ -203,16 +205,6 @@ public:
return this->d[i];
}
- inline bool operator==(const QScopedArrayPointer<T, Cleanup> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QScopedArrayPointer<T, Cleanup> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QScopedArrayPointer)
};
@@ -233,16 +225,6 @@ public:
return this->d;
}
- inline bool operator==(const QCustomScopedPointer<T, Cleanup> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QCustomScopedPointer<T, Cleanup> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QCustomScopedPointer)
};
@@ -287,16 +269,6 @@ public:
QScopedPointerSharedDeleter<T>::cleanup(oldD);
}
- inline bool operator==(const QScopedSharedPointer<T> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QScopedSharedPointer<T> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QScopedSharedPointer)
};