diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2016-05-03 23:19:49 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2016-06-08 09:09:47 +0000 |
commit | 982ef5b494319bfaaa585cf0620a821dc3b7c642 (patch) | |
tree | 25d87e709f3e12bf722f88716ad1ae18a976b783 /src/corelib/tools/qscopedpointer.h | |
parent | 997572d85918b1a660414b43a91c619cf294bd39 (diff) |
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 <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qscopedpointer.h')
-rw-r--r-- | src/corelib/tools/qscopedpointer.h | 24 |
1 files changed, 24 insertions, 0 deletions
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); } |