diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-07-12 15:23:08 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-07-20 12:56:18 +0200 |
commit | 0a3ff697380555538a0d035b768ddf10f772b55a (patch) | |
tree | ba8726ddb325def36b95e4707207852294448a40 /src/corelib/tools | |
parent | f8976a3e31ec07e191cd5bf27b64b030e3675748 (diff) |
Long live QT6_{DECL,IMPL,CALL}_NEW_OVERLOAD!
We have in the past found ourselves in need of disambiguating new
overloads from older, QT_REMOVED_SINCE'ed ones, which we usually did
by adding a defaulted int argument, cf. e.g. QMetaType::id().
The problem with a defaulted int argument is twofold: First, an int is
a valid argument type, and users may get confused as to its meaning
when presented with the signature in the IDEs auto-completion popup,
and a lot of things implicitly convert to an int, so any errornous
parameter passing may stay unnoticed until we remove these fake
arguments come Qt 7.
Second, this way of doing things requires a lot of ifdef'ery to keep
the additional argument out of both the docs and future Qt 7 builds.
The solution presented in this patch is to create a tag type,
QDisambiguated_t, which a) more clearly communicates its purpose and
b) doesn't implicitly convert from anything.
To help with the invariably ugly ifdef'ery, provide a set of macros
that hide this stuff from qdoc and Qt 7 builds.
Use the macros to replace the fake int arguments that were added for
6.4.
Pick-to: 6.4
Change-Id: I6916f38c8eb9793ad6dea5f61e7e5fff7e75e273
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qhashfunctions.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index 58f4afc94f..e9da071803 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -150,7 +150,8 @@ Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t se Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArrayView &key, size_t seed = 0) noexcept; #else Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QByteArrayView key, size_t seed = 0) noexcept; -inline Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t seed = 0 QT6_ONLY(, int = 0)) noexcept +inline Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t seed = 0 + QT6_DECL_NEW_OVERLOAD_TAIL) noexcept { return qHash(qToByteArrayViewIgnoringNull(key), seed); } #endif |