From df78bd62c3125366ce946274c0486090fd241466 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 20 Dec 2022 21:45:11 +0100 Subject: [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. Manual conflict resolutions: - swap() wasn't marked as noexcept in qsharedpointer.h, but is in qsharedpointer_impl.h, so kept the Qt 6 version. 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: Samuel Ghinet Reviewed-by: Fabian Kosmale --- src/corelib/tools/qsharedpointer.cpp | 49 ++++++++++++++++++++++++++++++++++++ src/corelib/tools/qsharedpointer.h | 10 +++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 7fe286fc5d..a0cfa0768d 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -478,6 +478,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) @@ -931,6 +971,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 15a4f26880..c1c926edb0 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -82,7 +82,12 @@ public: QSharedPointer &operator=(const QSharedPointer &other); QSharedPointer &operator=(const QWeakPointer &other); - void swap(QSharedPointer &other); + template + QSharedPointer(QSharedPointer && other) noexcept; + template + QSharedPointer &operator=(QSharedPointer && other) noexcept; + + void swap(QSharedPointer &other) noexcept; QWeakPointer toWeakRef() const; @@ -103,6 +108,9 @@ public: static inline QSharedPointer create(Args &&... args); }; +template +size_t qHash(const QSharedPointer &key, size_t seed = 0) noexcept; + template class QWeakPointer { -- cgit v1.2.3