QSharedPointer: document rvalue overloads of various cast methods

The patch provides two documentation snippets: for an arbitrary arg
and for \c {*this}. That is because qdoc does not support passing
a command (e.g. \c) as a part of the snippet's parameter.

Amends e95fb04202b3f786037c10942fd4e912644fd7d2.

Found in Qt 6.9 API review.

Change-Id: I4eed234d18e39f2fc0c30a647a423f3240e31d40
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 8511149d886e5aef2a065efffc336c7b25e6540e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2025-01-16 16:31:12 +01:00 committed by Qt Cherry-pick Bot
parent c965151d4d
commit 7e80af2bc2
2 changed files with 116 additions and 8 deletions

View File

@ -595,8 +595,24 @@
\sa isNull()
*/
/*
//! [cast-overload-for-this]
The returned QSharedPointer shares ownership with the same set of
shared owners as \c {*this}.
This function \l {reset()}{resets} \c {*this} to \nullptr on success.
//! [cast-overload-for-this]
//! [cast-overload-for-arg]
The returned QSharedPointer shares ownership with the same set of
shared owners as \a {\1}.
This function \l {reset()}{resets} \a {\1} to \nullptr on success.
//! [cast-overload-for-arg]
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::staticCast() const
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::staticCast() const &
Performs a static cast from this pointer's type to \tt X and returns
a QSharedPointer that shares the reference. This function can be
@ -611,7 +627,17 @@
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::dynamicCast() const
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::staticCast() &&
\since 6.9
\overload staticCast()
\include qsharedpointer.cpp {cast-overload-for-this}
\sa dynamicCast(), constCast(), qSharedPointerCast()
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::dynamicCast() const &
Performs a dynamic cast from this pointer's type to \tt X and
returns a QSharedPointer that shares the reference. If this
@ -628,7 +654,17 @@
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::constCast() const
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::dynamicCast() &&
\since 6.9
\overload dynamicCast()
\include qsharedpointer.cpp {cast-overload-for-this}
\sa qSharedPointerDynamicCast()
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::constCast() const &
Performs a \tt const_cast from this pointer's type to \tt X and returns
a QSharedPointer that shares the reference. This function can be
@ -639,7 +675,17 @@
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::objectCast() const
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::constCast() &&
\since 6.9
\overload constCast()
\include qsharedpointer.cpp {cast-overload-for-this}
\sa isNull(), qSharedPointerConstCast()
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::objectCast() const &
\since 4.6
Performs a \l qobject_cast() from this pointer's type to \tt X and
@ -656,6 +702,16 @@
\sa qSharedPointerObjectCast()
*/
/*!
\fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::objectCast() &&
\since 6.9
\overload objectCast()
\include qsharedpointer.cpp {cast-overload-for-this}
\sa qSharedPointerObjectCast()
*/
/*!
\fn template <class T> template <typename... Args> QSharedPointer<T> QSharedPointer<T>::create(Args &&... args)
\overload
@ -1194,6 +1250,17 @@
\sa QSharedPointer::staticCast(), qSharedPointerDynamicCast(), qSharedPointerConstCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerCast(QSharedPointer<T> &&other)
\relates QSharedPointer
\since 6.9
\overload qSharedPointerCast(const QSharedPointer<T> &other)
\include qsharedpointer.cpp {cast-overload-for-arg} {other}
\sa QSharedPointer::staticCast(), qSharedPointerDynamicCast(), qSharedPointerConstCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other)
\relates QSharedPointer
@ -1231,6 +1298,17 @@
\sa QSharedPointer::dynamicCast(), qSharedPointerCast(), qSharedPointerConstCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(QSharedPointer<T> &&src)
\relates QSharedPointer
\since 6.9
\overload qSharedPointerDynamicCast(const QSharedPointer<T> &src)
\include qsharedpointer.cpp {cast-overload-for-arg} {src}
\sa QSharedPointer::dynamicCast(), qSharedPointerCast(), qSharedPointerConstCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src)
\relates QSharedPointer
@ -1265,6 +1343,17 @@
\sa QSharedPointer::constCast(), qSharedPointerCast(), qSharedPointerDynamicCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(QSharedPointer<T> &&src)
\relates QSharedPointer
\since 6.9
\overload qSharedPointerConstCast(const QSharedPointer<T> &src)
\include qsharedpointer.cpp {cast-overload-for-arg} {src}
\sa QSharedPointer::constCast(), qSharedPointerCast(), qSharedPointerDynamicCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src)
\relates QSharedPointer
@ -1302,6 +1391,17 @@
\sa QSharedPointer::objectCast(), qSharedPointerCast(), qSharedPointerConstCast()
*/
/*!
\fn template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(QSharedPointer<T> &&src)
\relates QSharedPointer
\since 6.9
\overload qSharedPointerObjectCast(const QSharedPointer<T> &src)
\include qsharedpointer.cpp {cast-overload-for-arg} {src}
\sa QSharedPointer::objectCast(), qSharedPointerCast(), qSharedPointerConstCast()
*/
/*!
\fn template <class X, class T> std::shared_ptr<X> qSharedPointerObjectCast(const std::shared_ptr<T> &src)
\relates QSharedPointer

View File

@ -65,10 +65,14 @@ public:
void reset(T *t, Deleter deleter);
// casts:
template <class X> QSharedPointer<X> staticCast() const;
template <class X> QSharedPointer<X> dynamicCast() const;
template <class X> QSharedPointer<X> constCast() const;
template <class X> QSharedPointer<X> objectCast() const;
template <class X> QSharedPointer<X> staticCast() const &;
template <class X> QSharedPointer<X> staticCast() &&;
template <class X> QSharedPointer<X> dynamicCast() const &;
template <class X> QSharedPointer<X> dynamicCast() &&;
template <class X> QSharedPointer<X> constCast() const &;
template <class X> QSharedPointer<X> constCast() &&;
template <class X> QSharedPointer<X> objectCast() const &;
template <class X> QSharedPointer<X> objectCast() &&;
template <typename... Args>
static inline QSharedPointer<T> create(Args &&... args);
@ -164,12 +168,16 @@ template<class T> bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs);
template<class T> bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(QSharedPointer<T> &&other);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other);
template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src);
template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(QSharedPointer<T> &&src);
template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src);
template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src);
template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(QSharedPointer<T> &&src);
template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src);
template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(const QSharedPointer<T> &src);
template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(QSharedPointer<T> &&src);
template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(const QWeakPointer<T> &src);
template <typename X, class T> std::shared_ptr<X> qobject_pointer_cast(const std::shared_ptr<T> &src);
template <typename X, class T> std::shared_ptr<X> qobject_pointer_cast(std::shared_ptr<T> &&src);