summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2016-08-08 09:41:57 +0200
committerKai Koehne <kai.koehne@qt.io>2016-11-09 09:13:29 +0000
commit615270a3008cfc1314a3c983b7e69006dc4184b4 (patch)
tree77e2c1cc878c33744ef59a621aaff85bafa0e2c3
parent5c3b16706ff30c38258df0e98e071bf8ae6a1460 (diff)
downloadqtbase-615270a3008cfc1314a3c983b7e69006dc4184b4.tar.gz
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 <thiago.macieira@intel.com>
-rw-r--r--src/corelib/global/qflags.h2
-rw-r--r--src/corelib/global/qtypetraits.h41
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp8
3 files changed, 26 insertions, 25 deletions
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<Enum>::value,
+ QtPrivate::QIsUnsignedEnum<Enum>::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 <typename T>
-struct is_unsigned
+struct QIsUnsignedEnum
: std::integral_constant<bool, (T(0) < T(-1))> {};
// Checks whether a type is signed (T must be convertible to int):
template <typename T>
-struct is_signed
- : not_< is_unsigned<T> > {};
+struct QIsSignedEnum
+ : not_< QIsUnsignedEnum<T> > {};
-Q_STATIC_ASSERT(( is_unsigned<quint8>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint8>::value));
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint8>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint8>::value));
-Q_STATIC_ASSERT((!is_signed<quint8>::value));
-Q_STATIC_ASSERT(( is_signed<qint8>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint8>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint8>::value));
-Q_STATIC_ASSERT(( is_unsigned<quint16>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint16>::value));
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint16>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint16>::value));
-Q_STATIC_ASSERT((!is_signed<quint16>::value));
-Q_STATIC_ASSERT(( is_signed<qint16>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint16>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint16>::value));
-Q_STATIC_ASSERT(( is_unsigned<quint32>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint32>::value));
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint32>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint32>::value));
-Q_STATIC_ASSERT((!is_signed<quint32>::value));
-Q_STATIC_ASSERT(( is_signed<qint32>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint32>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint32>::value));
-Q_STATIC_ASSERT(( is_unsigned<quint64>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint64>::value));
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint64>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint64>::value));
-Q_STATIC_ASSERT((!is_signed<quint64>::value));
-Q_STATIC_ASSERT(( is_signed<qint64>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint64>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint64>::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<Qt::MouseButton>::value ==
- QtPrivate::is_unsigned<Qt::MouseButtons::Int>::value));
+ Q_STATIC_ASSERT((QtPrivate::QIsUnsignedEnum<Qt::MouseButton>::value ==
+ QtPrivate::QIsUnsignedEnum<Qt::MouseButtons::Int>::value));
- Q_STATIC_ASSERT((QtPrivate::is_signed<Qt::AlignmentFlag>::value ==
- QtPrivate::is_signed<Qt::Alignment::Int>::value));
+ Q_STATIC_ASSERT((QtPrivate::QIsSignedEnum<Qt::AlignmentFlag>::value ==
+ QtPrivate::QIsSignedEnum<Qt::Alignment::Int>::value));
}
#if defined(Q_COMPILER_CLASS_ENUM)