Fix SFINAE constraint in flags debug streaming operator

So that it allows overloading.
Also move the type T declaration into the function scope, as it
could never be used as a constraint anyway, and we do not want
users to pass custom type there.

Amends 0c707c6ebece18677deaccccdfec5d48c587106f.

Found in 6.9 API review.

Change-Id: I086d65bdef7be2f9e0e67e96cc8a9ac76eaa5b0f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f1d2d47f609cfb3c4cf9b2a86072613b3c9e0642)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2025-01-21 12:26:09 +01:00 committed by Qt Cherry-pick Bot
parent faf10af206
commit b9c1d1f7a1

View File

@ -628,10 +628,10 @@ void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, Int value)
}
template <class Flags,
typename = std::enable_if_t<QtPrivate::IsQFlags<Flags>::value, void>,
typename T = typename Flags::enum_type>
std::enable_if_t<QtPrivate::IsQFlags<Flags>::value, bool> = true>
inline QDebug operator<<(QDebug debug, Flags flags)
{
using T = typename Flags::enum_type;
using UInt = typename QIntegerForSizeof<T>::Unsigned;
#if !defined(QT_NO_QOBJECT)
if constexpr (QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<Flags>::Value) {