From 4e57e3d915557dc00b4931727cf162a1742e73a2 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 8 Aug 2016 09:41:57 +0200 Subject: [PATCH 17/18] Rename QtPrivate::is_[un]signed to QtPrivate::Is[Un]signedEnum Any other use than for enums should use std::is_[un]signed. Make this explicit by renaming the type traits. Change-Id: I494158563c95c710e710d0d337f4e547006df171 Reviewed-by: Thiago Macieira Backport-Of: 615270a3008cfc1314a3c983b7e69006dc4184b4 (v5.8.0) --- src/corelib/global/qflags.h | 2 +- src/corelib/global/qtypetraits.h | 41 ++++++++++--------- .../auto/corelib/global/qflags/tst_qflags.cpp | 8 ++-- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index d2a6b51d90..dc0873aaad 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -97,7 +97,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 86593f7b11..c5d7cacd8d 100644 --- a/src/corelib/global/qtypetraits.h +++ b/src/corelib/global/qtypetraits.h @@ -41,7 +41,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: @@ -51,37 +52,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 1f2e7ca0cd..f16b5c4cf7 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -138,11 +138,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) -- 2.25.1