diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index bbff1d2926b..d077057aaa8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -95,6 +95,40 @@ # error Qt major version not 6 or 7 #endif +/* Macro and tag type to help overload resolution on functions + that are, e.g., QT_REMOVED_SINCE'ed. Example use: + + #if QT_CORE_REMOVED_SINCE(6, 4) + int size() const; + #endif + qsizetype size(QT6_DECL_NEW_OVERLOAD) const; + + in the normal cpp file: + + qsizetype size(QT6_IMPL_NEW_OVERLOAD) const { + ~~~ + } + + in removed_api.cpp: + + int size() const { return int(size(QT6_CALL_NEW_OVERLOAD)); } +*/ +#ifdef Q_CLANG_QDOC +# define QT6_DECL_NEW_OVERLOAD +# define QT6_DECL_NEW_OVERLOAD_TAIL +# define QT6_IMPL_NEW_OVERLOAD +# define QT6_IMPL_NEW_OVERLOAD_TAIL +# define QT6_CALL_NEW_OVERLOAD +# define QT6_CALL_NEW_OVERLOAD_TAIL +#else +# define QT6_DECL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t = Qt::Disambiguated) +# define QT6_DECL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_DECL_NEW_OVERLOAD) +# define QT6_IMPL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t) +# define QT6_IMPL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_IMPL_NEW_OVERLOAD) +# define QT6_CALL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated) +# define QT6_CALL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT_CALL_NEW_OVERLOAD) +#endif + /* These two macros makes it possible to turn the builtin line expander into a * string literal. */ #define QT_STRINGIFY2(x) #x diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index dd70e91a8f3..5c8ed2e8e5b 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 diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 000001c1bfe..23e3e9736be 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -3009,6 +3009,11 @@ \internal */ +/*! + \enum Qt::Disambiguated_t + \internal +*/ + /*! \enum Qt::CoordinateSystem \since 4.6 diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index 58f4afc94f3..e9da0718031 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