From 639ce9e55edce0999061bd323b21d4c39d7265e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 8 Mar 2018 16:26:28 -0800 Subject: Add nullptr comparison to Q{Explicitly,}SharedDataPointer [ChangeLog][QtCore][QSharedDataPointer] Added operator== for nullptr. [ChangeLog][QtCore][QExplicitlySharedDataPointer] Added operator== for nullptr. Task-number: QTBUG-66635 Task-number: QTBUG-66946 Change-Id: I72f5230ad59948f784eafffd151a18e34384d844 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qshareddata.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/corelib/tools/qshareddata.h') diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index dbf0907a0f..f5572f3a00 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -132,6 +132,18 @@ private: T *d; }; +template inline bool operator==(std::nullptr_t p1, const QSharedDataPointer &p2) +{ + Q_UNUSED(p1); + return !p2; +} + +template inline bool operator==(const QSharedDataPointer &p1, std::nullptr_t p2) +{ + Q_UNUSED(p2); + return !p1; +} + template class QExplicitlySharedDataPointer { public: @@ -263,6 +275,18 @@ Q_INLINE_TEMPLATE QExplicitlySharedDataPointer::QExplicitlySharedDataPointer( : d(adata) { if (d) d->ref.ref(); } +template inline bool operator==(std::nullptr_t p1, const QExplicitlySharedDataPointer &p2) +{ + Q_UNUSED(p1); + return !p2; +} + +template inline bool operator==(const QExplicitlySharedDataPointer &p1, std::nullptr_t p2) +{ + Q_UNUSED(p2); + return !p1; +} + template Q_INLINE_TEMPLATE void qSwap(QSharedDataPointer &p1, QSharedDataPointer &p2) { p1.swap(p2); } -- cgit v1.2.3