From ee981bac2ae81b31877c01be5a36765c47ed99e8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 20 Dec 2022 21:45:11 +0100 Subject: [PATCH] [doc] QSharedPointer: add some missing docs Added docs for - move-ctor, -assignment operator - move-construction and -assignment from QSP - qHash() There's more stuff missing, but I declare 'twas enough qdoc wrangling for this round. The texts are taken from other smart pointer docs, esp. QESDP, so they're consistent. Fixes: QTBUG-83134 Fixes: QTBUG-63700 Change-Id: Iff980d043e1635ed6cfdd3113c68bc23f3a0bad7 Reviewed-by: Qt CI Bot Reviewed-by: Leena Miettinen Reviewed-by: Thiago Macieira (cherry picked from commit 5dc0f52e7047ca5927e6741fda554cb090184b71) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qsharedpointer.cpp | 49 ++++++++++++++++++++++++++++ src/corelib/tools/qsharedpointer.h | 8 +++++ 2 files changed, 57 insertions(+) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 65c1c144f14..3fa9bbd0d81 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -442,6 +442,46 @@ get a compiler error. */ +/*! + \fn template QSharedPointer::QSharedPointer(QSharedPointer &&other) + + Move-constructs a QSharedPointer instance, making it point at the same + object that \a other was pointing to. + + \since 5.4 +*/ + +/*! + \fn template QSharedPointer::operator=(QSharedPointer &&other) + + Move-assigns \a other to this QSharedPointer instance. + + \since 5.0 +*/ + +/*! + \fn template template QSharedPointer::QSharedPointer(QSharedPointer &&other) + + Move-constructs a QSharedPointer instance, making it point at the same + object that \a other was pointing to. + + This constructor participates in overload resolution only if \c{X*} + implicitly converts to \c{T*}. + + \since 5.6 +*/ + +/*! + \fn template template QSharedPointer::operator=(QSharedPointer &&other) + + Move-assigns \a other to this QSharedPointer instance. + + This assignment operator participates in overload resolution only if \c{X*} + implicitly converts to \c{T*}. + + \since 5.6 +*/ + /*! \fn template QSharedPointer::QSharedPointer(const QWeakPointer &other) @@ -895,6 +935,15 @@ Const overload of sharedFromThis(). */ +/*! + \fn template qHash(const QSharedPointer &key, size_t seed) + \relates QSharedPointer + + Returns the hash value for \a key, using \a seed to seed the calculation. + + \since 5.0 +*/ + /*! \fn template template bool operator==(const QSharedPointer &ptr1, const QSharedPointer &ptr2) \relates QSharedPointer diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index a18304cae6e..2a60f3ca5e2 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -48,6 +48,11 @@ public: QSharedPointer &operator=(QSharedPointer &&other) noexcept; QSharedPointer &operator=(const QWeakPointer &other); + template + QSharedPointer(QSharedPointer && other) noexcept; + template + QSharedPointer &operator=(QSharedPointer && other) noexcept; + void swap(QSharedPointer &other) noexcept; QWeakPointer toWeakRef() const; @@ -69,6 +74,9 @@ public: static inline QSharedPointer create(Args &&... args); }; +template +size_t qHash(const QSharedPointer &key, size_t seed = 0) noexcept; + template class QWeakPointer {