path: root/src/corelib/global/qflags.h
diff options
authorGiuseppe D'Angelo <>2016-11-03 16:08:55 +0000
committerGiuseppe D'Angelo <>2017-01-12 22:16:06 +0000
commit6255cb893d411b055758f2e64e94fde0bce91ea8 (patch)
treed8e445c85d6cd386c2228776001b372d01fbbef7 /src/corelib/global/qflags.h
parenta4c25c020554527aa9ff9b533afabffef46be131 (diff)
Remove qtypetraits.h's contents altogether
So that QFlags can use an (un)signed int matching the underlying type as identified by the compiler and not by us. Requires fixing a few warnings about sign conversion due to QFlags misusages in qtbase that were either plain wrong, or were relying on the enum being backed by an (un)signed int when it wasn't. Keep qtypetraits.h in the source tree in order to prevent source breaks if some downstream #includes it (note however that it did not contain any public API). Change-Id: Ib3a92b98db7031e793a088fb2a3b306eff4d7a3c Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src/corelib/global/qflags.h')
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index b871c90c9d..89a0ae9083 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -42,13 +42,12 @@
#ifndef QFLAGS_H
#define QFLAGS_H
-#include <QtCore/qtypeinfo.h>
-#include <QtCore/qtypetraits.h>
#include <initializer_list>
+#include <type_traits>
class QFlag
@@ -94,6 +93,8 @@ class QFlags
Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
"QFlags uses an int as storage, so an enum with underlying "
"long long will overflow.");
+ Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
struct Private;
typedef int (Private::*Zero);
@@ -103,7 +104,7 @@ public:
typedef int Int;
typedef typename std::conditional<
- QtPrivate::QIsUnsignedEnum<Enum>::value,
+ std::is_unsigned<typename std::underlying_type<Enum>::type>::value,
unsigned int,
signed int
>::type Int;