summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qscopedpointer.cpp42
-rw-r--r--src/corelib/tools/qscopedpointer.h24
-rw-r--r--src/corelib/tools/qsharedpointer.cpp84
-rw-r--r--src/corelib/tools/qsharedpointer.h8
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h48
5 files changed, 206 insertions, 0 deletions
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 1a37e0bc9c..67d11660e1 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -193,6 +193,48 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
\fn bool QScopedPointer::isNull() const
Returns \c true if this object is holding a pointer that is \c null.
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 18fbe2c808..92d7df6e5d 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -188,6 +188,30 @@ inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPoint
}
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template <class T, class Cleanup>
inline void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) Q_DECL_NOTHROW
{ p1.swap(p2); }
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 939a1bdffd..af09ef6f40 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1148,6 +1148,90 @@
*/
/*!
+ \fn bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
\fn bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 6b38f0e80c..3b86eb238b 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -149,6 +149,14 @@ template<class T, class X> bool operator==(const QWeakPointer<T> &ptr1, const QS
template<class T, class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
+template<class T> bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other);
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index dc118d7a68..0f769ffa86 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -822,6 +822,54 @@ bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DE
return ptr2 != ptr1;
}
+template<class T>
+inline bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template<class T>
+inline bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
//
// operator-
//