From 982ef5b494319bfaaa585cf0620a821dc3b7c642 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 3 May 2016 23:19:49 +0200 Subject: QSharedPointer/QWeakPointer/QScopedPointer: add comparison against nullptr Some constructors were added, but the comparison operators were missing. The STL has them, so we ought have them too. Change-Id: I030c14a3b355988f509716b4b1b1a835b3ab9481 Reviewed-by: Marc Mutz --- src/corelib/tools/qscopedpointer.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/corelib/tools/qscopedpointer.h') 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 @@ -187,6 +187,30 @@ inline bool operator!=(const QScopedPointer &lhs, const QScopedPoint return lhs.data() != rhs.data(); } +template +inline bool operator==(const QScopedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +{ + return lhs.isNull(); +} + +template +inline bool operator==(std::nullptr_t, const QScopedPointer &rhs) Q_DECL_NOTHROW +{ + return rhs.isNull(); +} + +template +inline bool operator!=(const QScopedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +{ + return !lhs.isNull(); +} + +template +inline bool operator!=(std::nullptr_t, const QScopedPointer &rhs) Q_DECL_NOTHROW +{ + return !rhs.isNull(); +} + template inline void swap(QScopedPointer &p1, QScopedPointer &p2) Q_DECL_NOTHROW { p1.swap(p2); } -- cgit v1.2.3