From ed7f77071dcca996a8c8147fd66344090666e60c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 5 Aug 2016 10:12:12 +0200 Subject: Replace custom type traits with std one's Remove most type traits from qtypetraits.h, but keep the custom implementation of is_signed/is_unsigned. This gets rid of BSD-3 licensed code from Google in a public header (hugh!). The custom implementations for is_signed/is_unsigned are kept because the implementations in gcc's standard headers do not work as we expect for enums - both is_signed and is_unsigned always returns false there - see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59027 [ChangeLog][QtCore][General] Qt now relies on type traits from the C++ standard library. Change-Id: I3f2188b46949f04ca4482a6ac9afd3482103f0e1 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.h | 9 ++++----- src/corelib/kernel/qobject.h | 12 ++++++------ src/corelib/kernel/qpointer.h | 2 +- src/corelib/kernel/qtimer.h | 8 ++++---- src/corelib/kernel/qvariant_p.h | 10 +++++----- 5 files changed, 20 insertions(+), 21 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 9e2a5bf75d..29e60b0eb5 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -46,7 +46,6 @@ #include #include #include -#include #ifndef QT_NO_QOBJECT #include #endif @@ -887,7 +886,7 @@ private: // is void* to avoid overloads conflicts. We do it by injecting unaccessible Dummy // type as part of the overload signature. struct Dummy {}; - typedef typename QtPrivate::if_::value, Dummy, value_type>::type value_type_OR_Dummy; + typedef typename std::conditional::value, Dummy, value_type>::type value_type_OR_Dummy; public: static void assign(void **ptr, const value_type_OR_Dummy *iterator ) { @@ -1092,7 +1091,7 @@ struct QSequentialIterableConvertFunctor } namespace QtMetaTypePrivate { -template::value> +template::value> struct AssociativeContainerAccessor { static const typename T::key_type& getKey(const typename T::const_iterator &it) @@ -1106,7 +1105,7 @@ struct AssociativeContainerAccessor } }; -template >::value> +template >::value> struct StlStyleAssociativeContainerAccessor; template @@ -1787,7 +1786,7 @@ template struct QMetaTypeIdQObject { enum { - Defined = QtPrivate::is_default_constructible::value + Defined = std::is_default_constructible::value }; static int qt_metatype_id() diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 3cec9802dc..69b70ad6ec 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -155,14 +155,14 @@ public: template inline T findChild(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { - typedef typename QtPrivate::remove_cv::type>::type ObjType; + typedef typename std::remove_cv::type>::type ObjType; return static_cast(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options)); } template inline QList findChildren(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { - typedef typename QtPrivate::remove_cv::type>::type ObjType; + typedef typename std::remove_cv::type>::type ObjType; QList list; qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); @@ -173,7 +173,7 @@ public: template inline QList findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { - typedef typename QtPrivate::remove_cv::type>::type ObjType; + typedef typename std::remove_cv::type>::type ObjType; QList list; qt_qFindChildren_helper(this, re, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); @@ -185,7 +185,7 @@ public: template inline QList findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { - typedef typename QtPrivate::remove_cv::type>::type ObjType; + typedef typename std::remove_cv::type>::type ObjType; QList list; qt_qFindChildren_helper(this, re, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); @@ -493,7 +493,7 @@ inline QT_DEPRECATED QList qFindChildren(const QObject *o, const QRegExp &re) template inline T qobject_cast(QObject *object) { - typedef typename QtPrivate::remove_cv::type>::type ObjType; + typedef typename std::remove_cv::type>::type ObjType; Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); return static_cast(ObjType::staticMetaObject.cast(object)); @@ -502,7 +502,7 @@ inline T qobject_cast(QObject *object) template inline T qobject_cast(const QObject *object) { - typedef typename QtPrivate::remove_cv::type>::type ObjType; + typedef typename std::remove_cv::type>::type ObjType; Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); return static_cast(ObjType::staticMetaObject.cast(object)); diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index b5c17ad394..b2b3cda4ab 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -52,7 +52,7 @@ class QVariant; template class QPointer { - Q_STATIC_ASSERT_X(!QtPrivate::is_pointer::value, "QPointer's template type must not be a pointer type"); + Q_STATIC_ASSERT_X(!std::is_pointer::value, "QPointer's template type must not be a pointer type"); template struct TypeSelector diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 4f934d0367..96c7efd8f5 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -119,14 +119,14 @@ public: // singleShot to a functor or function pointer (without context) template static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !QtPrivate::is_same::value, void>::Type + !std::is_same::value, void>::Type singleShot(Duration interval, Func1 slot) { singleShot(interval, defaultTypeFor(interval), nullptr, slot); } template static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !QtPrivate::is_same::value, void>::Type + !std::is_same::value, void>::Type singleShot(Duration interval, Qt::TimerType timerType, Func1 slot) { singleShot(interval, timerType, nullptr, slot); @@ -134,14 +134,14 @@ public: // singleShot to a functor or function pointer (with context) template static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !QtPrivate::is_same::value, void>::Type + !std::is_same::value, void>::Type singleShot(Duration interval, QObject *context, Func1 slot) { singleShot(interval, defaultTypeFor(interval), context, slot); } template static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !QtPrivate::is_same::value, void>::Type + !std::is_same::value, void>::Type singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot) { //compilation error if the slot has arguments. diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index d01f386032..ec87e20656 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -66,7 +66,7 @@ struct QVariantIntegrator { static const bool CanUseInternalSpace = sizeof(T) <= sizeof(QVariant::Private::Data) && ((QTypeInfoQuery::isRelocatable) || Q_IS_ENUM(T)); - typedef QtPrivate::integral_constant CanUseInternalSpace_t; + typedef std::integral_constant CanUseInternalSpace_t; }; Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); @@ -118,28 +118,28 @@ private: }; template -inline void v_construct_helper(QVariant::Private *x, const T &t, QtPrivate::true_type) +inline void v_construct_helper(QVariant::Private *x, const T &t, std::true_type) { new (&x->data) T(t); x->is_shared = false; } template -inline void v_construct_helper(QVariant::Private *x, const T &t, QtPrivate::false_type) +inline void v_construct_helper(QVariant::Private *x, const T &t, std::false_type) { x->data.shared = new QVariantPrivateSharedEx(t); x->is_shared = true; } template -inline void v_construct_helper(QVariant::Private *x, QtPrivate::true_type) +inline void v_construct_helper(QVariant::Private *x, std::true_type) { new (&x->data) T(); x->is_shared = false; } template -inline void v_construct_helper(QVariant::Private *x, QtPrivate::false_type) +inline void v_construct_helper(QVariant::Private *x, std::false_type) { x->data.shared = new QVariantPrivateSharedEx; x->is_shared = true; -- cgit v1.2.3