diff options
| author | Rym Bouabid <rym.bouabid@qt.io> | 2024-04-03 18:52:59 +0200 |
|---|---|---|
| committer | Rym Bouabid <rym.bouabid@qt.io> | 2024-07-04 22:08:12 +0200 |
| commit | 793f3d8642139e9411ee0ec7999d8d8273b22241 (patch) | |
| tree | 5483cebb846925292edcee5b0bcece20732e6d92 /src/corelib/tools/qshareddata.cpp | |
| parent | 7131240754d4caa3891f667b4645d8915cb82535 (diff) | |
QExplicitlySharedDataPointer: Use new comparison helper macros
Provide the new comparesEqual() helper function as an implementation of
the (in)equality operators and compareThreeWay() helper function for
the rest of the relational operators.
Use Q_DECLARE_STRONGLY_ORDERED to provide all relational operators.
Use the new Qt::totally_ordered_wrapper to wrap the "d" pointer to
avoid UB when performing comparisons of QExplicitlySharedDataPointer.
Add some comparisons related tests for QExplicitlySharedDataPointer.
Use QT_TEST_ALL_COMPARISON_OPS macros in unit-tests.
Task-number: QTBUG-120306
Change-Id: I275484a96a57da2df92712ac97e237a88a889da5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/tools/qshareddata.cpp')
| -rw-r--r-- | src/corelib/tools/qshareddata.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index ffc13f7d695..2f8cf98230c 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -443,6 +443,10 @@ QT_BEGIN_NAMESPACE \since 4.4 \reentrant + \compares strong + \compareswith strong T* std::nullptr_t + \endcompareswith + QExplicitlySharedDataPointer\<T\> makes writing your own explicitly shared classes easy. QExplicitlySharedDataPointer implements \l {thread-safe} reference counting, ensuring that adding @@ -520,8 +524,8 @@ QT_BEGIN_NAMESPACE \since 5.2 */ -/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator==(const T* ptr, const QExplicitlySharedDataPointer<T>& rhs) - Returns \c true if the \e{d pointer} of \a rhs is \a ptr. +/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator==(const T* const &lhs, const QExplicitlySharedDataPointer<T>& rhs) + Returns \c true if the \e{d pointer} of \a rhs is \a lhs. */ /*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator!=(const QExplicitlySharedDataPointer<T>& lhs, const QExplicitlySharedDataPointer<T>& rhs) @@ -529,8 +533,8 @@ QT_BEGIN_NAMESPACE \e{d pointer}. */ -/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator!=(const T* ptr, const QExplicitlySharedDataPointer<T>& rhs) - Returns \c true if the \e{d pointer} of \a rhs is \e not \a ptr. +/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator!=(const T* const &lhs, const QExplicitlySharedDataPointer<T>& rhs) + Returns \c true if the \e{d pointer} of \a rhs is \e not \a lhs. */ /*! \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer() |
