QNativeIpcKey: normalize docs for qHash()

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 <ivan.solovev@qt.io>
(cherry picked from commit 27d792869b30721cecf493a54d89e9df6e75a6fa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-11-19 11:11:58 +01:00 committed by Qt Cherry-pick Bot
parent 296bae3f10
commit ca1b4baf09
2 changed files with 4 additions and 6 deletions

View File

@ -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

View File

@ -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;