diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 5dfc4614f91..1da9a48b602 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -652,28 +652,36 @@ public: // std::weak_ptr compatibility: [[nodiscard]] QSharedPointer lock() const { return toStrongRef(); } +#if QT_DEPRECATED_SINCE(6, 7) template + QT_DEPRECATED_VERSION_X_6_7("Comparison of QWeakPointers is inconsistent and may lead to crashes. lock() them and then compare the resulting QSharedPointers.") bool operator==(const QWeakPointer &o) const noexcept { return d == o.d && value == static_cast(o.value); } template + QT_DEPRECATED_VERSION_X_6_7("Comparison of QWeakPointers is inconsistent and may lead to crashes. lock() them and then compare the resulting QSharedPointers.") bool operator!=(const QWeakPointer &o) const noexcept { return !(*this == o); } template + QT_DEPRECATED_VERSION_X_6_7("Comparison of QWeakPointers is inconsistent and may lead to crashes. lock() them and then compare the resulting QSharedPointers.") bool operator==(const QSharedPointer &o) const noexcept { return d == o.d; } template + QT_DEPRECATED_VERSION_X_6_7("Comparison of QWeakPointers is inconsistent and may lead to crashes. lock() them and then compare the resulting QSharedPointers.") bool operator!=(const QSharedPointer &o) const noexcept { return !(*this == o); } template + QT_DEPRECATED_VERSION_X_6_7("Comparison of QWeakPointers is inconsistent and may lead to crashes. lock() them and then compare the resulting QSharedPointers.") friend bool operator==(const QSharedPointer &p1, const QWeakPointer &p2) noexcept { return p2 == p1; } template + QT_DEPRECATED_VERSION_X_6_7("Comparison of QWeakPointers is inconsistent and may lead to crashes. lock() them and then compare the resulting QSharedPointers.") friend bool operator!=(const QSharedPointer &p1, const QWeakPointer &p2) noexcept { return p2 != p1; } +#endif friend bool operator==(const QWeakPointer &p, std::nullptr_t) { return p.isNull(); }