diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-27 23:56:35 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-28 20:36:18 +0100 |
commit | 39aa070e969621512b67cac39c995781478d806b (patch) | |
tree | 83cd469819f461640b54f065f35b173b8544c944 /src/gui | |
parent | a3d71792ca018b1cff06dbefde20f6f4e06ee704 (diff) |
QSurfaceFormat: Make comparison operators hidden friends
Reduce ADL noise. Also add noexcept.
Task-number: QTBUG-87973
Change-Id: I83787264b00b084ecdc85b6b3c2a8d95db94a05e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 48 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.h | 10 |
2 files changed, 29 insertions, 29 deletions
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 366e68ebe3..647ed8eaca 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -831,37 +831,37 @@ QSurfaceFormat QSurfaceFormat::defaultFormat() } /*! - Returns \c true if all the options of the two QSurfaceFormat objects - \a a and \a b are equal. + \fn bool QSurfaceFormat::operator==(const QSurfaceFormat& lhs, const QSurfaceFormat& rhs) - \relates QSurfaceFormat + Returns \c true if all the options of the two QSurfaceFormat objects + \a lhs and \a rhs are equal. */ -bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b) -{ - return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts - && a.d->stencilSize == b.d->stencilSize - && a.d->redBufferSize == b.d->redBufferSize - && a.d->greenBufferSize == b.d->greenBufferSize - && a.d->blueBufferSize == b.d->blueBufferSize - && a.d->alphaBufferSize == b.d->alphaBufferSize - && a.d->depthSize == b.d->depthSize - && a.d->numSamples == b.d->numSamples - && a.d->swapBehavior == b.d->swapBehavior - && a.d->profile == b.d->profile - && a.d->major == b.d->major - && a.d->minor == b.d->minor - && a.d->swapInterval == b.d->swapInterval); -} /*! + \fn bool QSurfaceFormat::operator!=(const QSurfaceFormat& lhs, const QSurfaceFormat& rhs) + Returns \c false if all the options of the two QSurfaceFormat objects - \a a and \a b are equal; otherwise returns \c true. + \a lhs and \a rhs are equal; otherwise returns \c true. +*/ - \relates QSurfaceFormat +/*! + \internal */ -bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b) -{ - return !(a == b); +bool QSurfaceFormat::equals(const QSurfaceFormat& other) const noexcept +{ + return (d == other.d) || ((int) d->opts == (int) other.d->opts + && d->stencilSize == other.d->stencilSize + && d->redBufferSize == other.d->redBufferSize + && d->greenBufferSize == other.d->greenBufferSize + && d->blueBufferSize == other.d->blueBufferSize + && d->alphaBufferSize == other.d->alphaBufferSize + && d->depthSize == other.d->depthSize + && d->numSamples == other.d->numSamples + && d->swapBehavior == other.d->swapBehavior + && d->profile == other.d->profile + && d->major == other.d->major + && d->minor == other.d->minor + && d->swapInterval == other.d->swapInterval); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h index bacbf2a987..b12c2b5f1d 100644 --- a/src/gui/kernel/qsurfaceformat.h +++ b/src/gui/kernel/qsurfaceformat.h @@ -162,17 +162,17 @@ private: QSurfaceFormatPrivate *d; void detach(); + bool equals(const QSurfaceFormat &other) const noexcept; - friend Q_GUI_EXPORT bool operator==(const QSurfaceFormat&, const QSurfaceFormat&); - friend Q_GUI_EXPORT bool operator!=(const QSurfaceFormat&, const QSurfaceFormat&); + friend inline bool operator==(const QSurfaceFormat &lhs, const QSurfaceFormat &rhs) noexcept + { return lhs.equals(rhs); } + friend inline bool operator!=(const QSurfaceFormat &lhs, const QSurfaceFormat &rhs) noexcept + { return !lhs.equals(rhs); } #ifndef QT_NO_DEBUG_STREAM friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &); #endif }; -Q_GUI_EXPORT bool operator==(const QSurfaceFormat&, const QSurfaceFormat&); -Q_GUI_EXPORT bool operator!=(const QSurfaceFormat&, const QSurfaceFormat&); - #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &); #endif |