diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-06-21 15:00:43 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-06-21 22:46:39 +0200 |
commit | 81d357ff8a7af8704ba5657caef04f28e7099625 (patch) | |
tree | 61ca7446441a1ffed38ce168183423ddd1f9a8ae /src/corelib/tools/qsharedpointer_impl.h | |
parent | 45ffb1790c25e4fbbbaafd9ddd936ef2dd819258 (diff) |
QWeakPointer: mark lock() [[nodiscard]]
The lock() function, added for std::weak_ptr compatibility, sounds
like QMutex::lock(), but is, in fact, a const function. QUIP-0019 says
such functions must be marked [[nodiscard]]. For symmetry, also mark
toStrongRef() and toWeakRef() as [[nodiscard]].
Pick-to: 6.6 6.5
Change-Id: Ifb6e447d2cd96fedd9a78decdfac6bc57c1d282a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qsharedpointer_impl.h')
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6006d4fe5d..7ac317eacb 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -393,7 +393,7 @@ public: inline void clear() { QSharedPointer copy; swap(copy); } - QWeakPointer<T> toWeakRef() const; + [[nodiscard]] QWeakPointer<T> toWeakRef() const; template <typename... Args> static QSharedPointer create(Args && ...arguments) @@ -633,9 +633,9 @@ public: inline void clear() { *this = QWeakPointer(); } - inline QSharedPointer<T> toStrongRef() const { return QSharedPointer<T>(*this); } + [[nodiscard]] QSharedPointer<T> toStrongRef() const { return QSharedPointer<T>(*this); } // std::weak_ptr compatibility: - inline QSharedPointer<T> lock() const { return toStrongRef(); } + [[nodiscard]] QSharedPointer<T> lock() const { return toStrongRef(); } template <class X> bool operator==(const QWeakPointer<X> &o) const noexcept |