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/global/qnamespace.h | |
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/global/qnamespace.h')
-rw-r--r-- | src/corelib/global/qnamespace.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index dd70e91a8f..5c8ed2e8e5 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1580,6 +1580,11 @@ namespace Qt { }; inline constexpr Initialization Uninitialized = Initialization::Uninitialized; + struct Disambiguated_t { + explicit Disambiguated_t() = default; + }; + inline constexpr Disambiguated_t Disambiguated{}; + enum CoordinateSystem { DeviceCoordinates, LogicalCoordinates |