diff options
Diffstat (limited to 'src/corelib/global/qflags.h')
-rw-r--r-- | src/corelib/global/qflags.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index d7b673bc1f..097f2760b4 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -57,16 +57,22 @@ class QFlag { int i; public: -#if !defined(__LP64__) && !defined(Q_QDOC) + Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {} + Q_DECL_CONSTEXPR inline operator int() const { return i; } + +#if !defined(Q_CC_MSVC) + // Microsoft Visual Studio has buggy behavior when it comes to + // unsigned enums: even if the enum is unsigned, the enum tags are + // always signed +# if !defined(__LP64__) && !defined(Q_QDOC) Q_DECL_CONSTEXPR inline QFlag(long ai) : i(int(ai)) {} Q_DECL_CONSTEXPR inline QFlag(ulong ai) : i(int(long(ai))) {} -#endif - Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {} +# endif Q_DECL_CONSTEXPR inline QFlag(uint ai) : i(int(ai)) {} Q_DECL_CONSTEXPR inline QFlag(short ai) : i(int(ai)) {} Q_DECL_CONSTEXPR inline QFlag(ushort ai) : i(int(uint(ai))) {} - Q_DECL_CONSTEXPR inline operator int() const { return i; } Q_DECL_CONSTEXPR inline operator uint() const { return uint(i); } +#endif }; Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE); @@ -93,7 +99,11 @@ class QFlags struct Private; typedef int (Private::*Zero); public: -#ifndef Q_QDOC +#if defined(Q_CC_MSVC) || defined(Q_QDOC) + // see above for MSVC + // the definition below is too complex for qdoc + typedef int Int; +#else typedef typename QtPrivate::if_< QtPrivate::is_unsigned<Enum>::value, unsigned int, @@ -103,7 +113,6 @@ public: typedef Enum enum_type; // compiler-generated copy/move ctor/assignment operators are fine! #ifdef Q_QDOC - typedef int Int; // the real typedef above is too complex for qdoc inline QFlags(const QFlags &other); inline QFlags &operator=(const QFlags &other); #endif |