diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index f85fc705b4..b871c90c9d 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -103,7 +103,7 @@ public: typedef int Int; #else typedef typename std::conditional< - QtPrivate::is_unsigned::value, + QtPrivate::QIsUnsignedEnum::value, unsigned int, signed int >::type Int; diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h index b664dd3a3e..9773db919b 100644 --- a/src/corelib/global/qtypetraits.h +++ b/src/corelib/global/qtypetraits.h @@ -47,7 +47,8 @@ QT_BEGIN_NAMESPACE namespace QtPrivate { // -// define custom is_signed, is_unsigned that also works with enum's +// Define QIsUnsignedEnum, QIsSignedEnum - +// std::is_signed, std::is_unsigned does not work for enum's // // a metafunction to invert an integral_constant: @@ -57,37 +58,37 @@ struct not_ // Checks whether a type is unsigned (T must be convertible to unsigned int): template -struct is_unsigned +struct QIsUnsignedEnum : std::integral_constant {}; // Checks whether a type is signed (T must be convertible to int): template -struct is_signed - : not_< is_unsigned > {}; +struct QIsSignedEnum + : not_< QIsUnsignedEnum > {}; -Q_STATIC_ASSERT(( is_unsigned::value)); -Q_STATIC_ASSERT((!is_unsigned::value)); +Q_STATIC_ASSERT(( QIsUnsignedEnum::value)); +Q_STATIC_ASSERT((!QIsUnsignedEnum::value)); -Q_STATIC_ASSERT((!is_signed::value)); -Q_STATIC_ASSERT(( is_signed::value)); +Q_STATIC_ASSERT((!QIsSignedEnum::value)); +Q_STATIC_ASSERT(( QIsSignedEnum::value)); -Q_STATIC_ASSERT(( is_unsigned::value)); -Q_STATIC_ASSERT((!is_unsigned::value)); +Q_STATIC_ASSERT(( QIsUnsignedEnum::value)); +Q_STATIC_ASSERT((!QIsUnsignedEnum::value)); -Q_STATIC_ASSERT((!is_signed::value)); -Q_STATIC_ASSERT(( is_signed::value)); +Q_STATIC_ASSERT((!QIsSignedEnum::value)); +Q_STATIC_ASSERT(( QIsSignedEnum::value)); -Q_STATIC_ASSERT(( is_unsigned::value)); -Q_STATIC_ASSERT((!is_unsigned::value)); +Q_STATIC_ASSERT(( QIsUnsignedEnum::value)); +Q_STATIC_ASSERT((!QIsUnsignedEnum::value)); -Q_STATIC_ASSERT((!is_signed::value)); -Q_STATIC_ASSERT(( is_signed::value)); +Q_STATIC_ASSERT((!QIsSignedEnum::value)); +Q_STATIC_ASSERT(( QIsSignedEnum::value)); -Q_STATIC_ASSERT(( is_unsigned::value)); -Q_STATIC_ASSERT((!is_unsigned::value)); +Q_STATIC_ASSERT(( QIsUnsignedEnum::value)); +Q_STATIC_ASSERT((!QIsUnsignedEnum::value)); -Q_STATIC_ASSERT((!is_signed::value)); -Q_STATIC_ASSERT(( is_signed::value)); +Q_STATIC_ASSERT((!QIsSignedEnum::value)); +Q_STATIC_ASSERT(( QIsSignedEnum::value)); } // namespace QtPrivate diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 10902b6f55..634d9a2df3 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -134,11 +134,11 @@ void tst_QFlags::signedness() // underlying type is implementation-defined, we need to allow for // a different signedness, so we only check that the relative // signedness of the types matches: - Q_STATIC_ASSERT((QtPrivate::is_unsigned::value == - QtPrivate::is_unsigned::value)); + Q_STATIC_ASSERT((QtPrivate::QIsUnsignedEnum::value == + QtPrivate::QIsUnsignedEnum::value)); - Q_STATIC_ASSERT((QtPrivate::is_signed::value == - QtPrivate::is_signed::value)); + Q_STATIC_ASSERT((QtPrivate::QIsSignedEnum::value == + QtPrivate::QIsSignedEnum::value)); } #if defined(Q_COMPILER_CLASS_ENUM)