From 10a88b8149e7699b08871a8a62892ac0f39b54f2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 26 Jul 2018 17:14:07 +0200 Subject: Add debug output for single enum flags They have a separate type that we can't recognize directly, but we can check if we can recognize the QFlags form, though we have to add a lot of template-conditions to avoid triggering QFlags static asserts. Change-Id: I00853682c5376dd3cc411ff151f47bce2389e277 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/io/qdebug.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/corelib/io/qdebug.h') diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index ee8ef679a9..ae1869f89e 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -376,6 +376,19 @@ operator<<(QDebug dbg, T value) return qt_QMetaEnum_debugOperator(dbg, typename QFlags::Int(value), obj, name); } +template::value, void>::type, + typename B = typename std::enable_if::type, + typename C = typename std::enable_if::Value, void>::type, + typename D = typename std::enable_if>::Value, void>::type> +inline QDebug operator<<(QDebug dbg, T value) +{ + typedef QFlags FlagsT; + const QMetaObject *obj = qt_getEnumMetaObject(FlagsT()); + const char *name = qt_getEnumName(FlagsT()); + return qt_QMetaEnum_debugOperator(dbg, typename FlagsT::Int(value), obj, name); +} + template inline typename std::enable_if< QtPrivate::IsQEnumHelper::Value || QtPrivate::IsQEnumHelper >::Value, -- cgit v1.2.3