From ca1b4baf09f033b9dd8ee4ab485aaa4f1961751e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 19 Nov 2024 11:11:58 +0100 Subject: [PATCH] QNativeIpcKey: normalize docs for qHash() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C++ standard forces¹ us to overload the hidden friend qHash() implementation instead of defaulting `seed` to zero. That doesn't mean we need to reflect that technicality in the docs, esp. if it forces us to deviate from the standard phrasing of qHash() functions to say something about the default value of `seed` (which would, for a defaulted argument, be shown in the docs). Present the qHash() function in the canonical form to QDoc. This is a (forwards and backwards) BC way to solve the issue. Going forward, the correct fix should be to have qHash() functions call a private hash(seed) member function instead, to fulfill the pointless requirement of [1]. ¹ [dcl.fct.default]/4, last sentence Amends c2310f8e03cf30222cea59b3c556d060e1710015. Task-number: QTBUG-129574 Change-Id: I7890a0df092c9780601fc4c25e23d70d92db47e1 Reviewed-by: Ivan Solovev (cherry picked from commit 27d792869b30721cecf493a54d89e9df6e75a6fa) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/ipc/qtipccommon.cpp | 6 ------ src/corelib/ipc/qtipccommon.h | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/corelib/ipc/qtipccommon.cpp b/src/corelib/ipc/qtipccommon.cpp index 553f3dd1996..2b71456bdc1 100644 --- a/src/corelib/ipc/qtipccommon.cpp +++ b/src/corelib/ipc/qtipccommon.cpp @@ -496,12 +496,6 @@ void QNativeIpcKey::setNativeKey_internal(const QString &) d->legacyKey_.clear(); } -/*! - \fn size_t QNativeIpcKey::qHash(const QNativeIpcKey &ipcKey) noexcept - - Returns the hash value for \a ipcKey, using a default seed of \c 0. -*/ - /*! \fn size_t QNativeIpcKey::qHash(const QNativeIpcKey &ipcKey, size_t seed) noexcept diff --git a/src/corelib/ipc/qtipccommon.h b/src/corelib/ipc/qtipccommon.h index 74f30cb6a44..d520a4dd682 100644 --- a/src/corelib/ipc/qtipccommon.h +++ b/src/corelib/ipc/qtipccommon.h @@ -153,9 +153,13 @@ private: constexpr bool isSlowPath() const noexcept { return Q_UNLIKELY(d); } +#ifdef Q_QDOC + friend size_t qHash(const QNativeIpcKey &ipcKey, size_t seed = 0) noexcept { return 0; } +#else friend Q_CORE_EXPORT size_t qHash(const QNativeIpcKey &ipcKey, size_t seed) noexcept; friend size_t qHash(const QNativeIpcKey &ipcKey) noexcept { return qHash(ipcKey, 0); } +#endif Q_CORE_EXPORT void copy_internal(const QNativeIpcKey &other); Q_CORE_EXPORT void move_internal(QNativeIpcKey &&other) noexcept;