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/tools/qbytearray_p.h | 3 +-- src/corelib/tools/qhash.h | 2 +- src/corelib/tools/qlist.h | 4 ++-- src/corelib/tools/qmap.h | 7 +++---- src/corelib/tools/qsharedpointer_impl.h | 2 +- src/corelib/tools/qstringalgorithms_p.h | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qbytearray_p.h b/src/corelib/tools/qbytearray_p.h index 0824611d99..6ebff739cd 100644 --- a/src/corelib/tools/qbytearray_p.h +++ b/src/corelib/tools/qbytearray_p.h @@ -52,14 +52,13 @@ // #include -#include #include "qtools_p.h" QT_BEGIN_NAMESPACE enum { // Define as enum to force inlining. Don't expose MaxAllocSize in a public header. - MaxByteArraySize = MaxAllocSize - sizeof(QtPrivate::remove_pointer::type) + MaxByteArraySize = MaxAllocSize - sizeof(std::remove_pointer::type) }; QT_END_NAMESPACE diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 6a2d7bdd11..d58c3c5733 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -764,7 +764,7 @@ Q_INLINE_TEMPLATE typename QHash::iterator QHash::insert(const K return iterator(createNode(h, akey, avalue, node)); } - if (!QtPrivate::is_same::value) + if (!std::is_same::value) (*node)->value = avalue; return iterator(*node); } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c7f27abdd6..c0a92aaa10 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -125,10 +125,10 @@ class QList { public: struct MemoryLayout - : QtPrivate::if_< + : std::conditional< QTypeInfo::isStatic || QTypeInfo::isLarge, QListData::IndirectLayout, - typename QtPrivate::if_< + typename std::conditional< sizeof(T) == sizeof(void*), QListData::ArrayCompatibleLayout, QListData::InlineWithPaddingLayout diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index baa10b7a95..96ce787446 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -44,7 +44,6 @@ #include #include #include -#include #ifdef Q_MAP_DEBUG #include @@ -130,15 +129,15 @@ struct QMapNode : public QMapNodeBase { callDestructorIfNecessary(key); callDestructorIfNecessary(value); - doDestroySubTree(QtPrivate::integral_constant::isComplex || QTypeInfo::isComplex>()); + doDestroySubTree(std::integral_constant::isComplex || QTypeInfo::isComplex>()); } QMapNode *lowerBound(const Key &key); QMapNode *upperBound(const Key &key); private: - void doDestroySubTree(QtPrivate::false_type) {} - void doDestroySubTree(QtPrivate::true_type) + void doDestroySubTree(std::false_type) {} + void doDestroySubTree(std::true_type) { if (left) leftNode()->destroySubTree(); diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index a0c22c9179..5738413bfb 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -464,7 +464,7 @@ private: template inline void enableSharedFromThis(const QEnableSharedFromThis *ptr) { - ptr->initializeFromSharedPointer(constCast::type>()); + ptr->initializeFromSharedPointer(constCast::type>()); } inline void enableSharedFromThis(...) {} diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h index d7127517e0..c5470bc7ad 100644 --- a/src/corelib/tools/qstringalgorithms_p.h +++ b/src/corelib/tools/qstringalgorithms_p.h @@ -60,8 +60,8 @@ template struct QStringAlgorithms { typedef typename StringType::value_type Char; typedef typename StringType::size_type size_type; - typedef typename QtPrivate::remove_cv::type NakedStringType; - static const bool isConst = QtPrivate::is_const::value; + typedef typename std::remove_cv::type NakedStringType; + static const bool isConst = std::is_const::value; static inline bool isSpace(char ch) { return ascii_isspace(ch); } static inline bool isSpace(QChar ch) { return ch.isSpace(); } -- cgit v1.2.3