Use std::enable_if instead of QEnableIf

Change-Id: Ideca8283141484cb6da47c50333f5c96e416f082
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Alexander Volkov 2017-01-20 15:58:10 +03:00
parent d03ba0e895
commit 30d0e1770c
16 changed files with 74 additions and 74 deletions

View File

@ -101,7 +101,7 @@ QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), con
#if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION) #if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION)
template <typename Functor> template <typename Functor>
auto run(Functor functor) -> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor())> >::Type auto run(Functor functor) -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor())>>::type
{ {
typedef decltype(functor()) result_type; typedef decltype(functor()) result_type;
return (new StoredFunctorCall0<result_type, Functor>(functor))->start(); return (new StoredFunctorCall0<result_type, Functor>(functor))->start();
@ -109,7 +109,7 @@ auto run(Functor functor) -> typename QtPrivate::QEnableIf<!QtPrivate::HasResult
template <typename Functor, typename Arg1> template <typename Functor, typename Arg1>
auto run(Functor functor, const Arg1 &arg1) auto run(Functor functor, const Arg1 &arg1)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1))>>::type
{ {
typedef decltype(functor(arg1)) result_type; typedef decltype(functor(arg1)) result_type;
return (new StoredFunctorCall1<result_type, Functor, Arg1>(functor, arg1))->start(); return (new StoredFunctorCall1<result_type, Functor, Arg1>(functor, arg1))->start();
@ -117,7 +117,7 @@ auto run(Functor functor, const Arg1 &arg1)
template <typename Functor, typename Arg1, typename Arg2> template <typename Functor, typename Arg1, typename Arg2>
auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2) auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2))>>::type
{ {
typedef decltype(functor(arg1, arg2)) result_type; typedef decltype(functor(arg1, arg2)) result_type;
return (new StoredFunctorCall2<result_type, Functor, Arg1, Arg2>(functor, arg1, arg2))->start(); return (new StoredFunctorCall2<result_type, Functor, Arg1, Arg2>(functor, arg1, arg2))->start();
@ -125,7 +125,7 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2)
template <typename Functor, typename Arg1, typename Arg2, typename Arg3> template <typename Functor, typename Arg1, typename Arg2, typename Arg3>
auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3))>>::type
{ {
typedef decltype(functor(arg1, arg2, arg3)) result_type; typedef decltype(functor(arg1, arg2, arg3)) result_type;
return (new StoredFunctorCall3<result_type, Functor, Arg1, Arg2, Arg3>(functor, arg1, arg2, arg3))->start(); return (new StoredFunctorCall3<result_type, Functor, Arg1, Arg2, Arg3>(functor, arg1, arg2, arg3))->start();
@ -133,7 +133,7 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4> template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4))>>::type
{ {
typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type;
return (new StoredFunctorCall4<result_type, Functor, Arg1, Arg2, Arg3, Arg4>(functor, arg1, arg2, arg3, arg4))->start(); return (new StoredFunctorCall4<result_type, Functor, Arg1, Arg2, Arg3, Arg4>(functor, arg1, arg2, arg3, arg4))->start();
@ -141,7 +141,7 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3,
template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4, arg5))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4, arg5))>>::type
{ {
typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type;
return (new StoredFunctorCall5<result_type, Functor, Arg1, Arg2, Arg3, Arg4, Arg5>(functor, arg1, arg2, arg3, arg4, arg5))->start(); return (new StoredFunctorCall5<result_type, Functor, Arg1, Arg2, Arg3, Arg4, Arg5>(functor, arg1, arg2, arg3, arg4, arg5))->start();
@ -372,7 +372,7 @@ QFuture<T> run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, P
#if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION) #if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION)
template <typename Functor> template <typename Functor>
auto run(QThreadPool *pool, Functor functor) -> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor())> >::Type auto run(QThreadPool *pool, Functor functor) -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor())>>::type
{ {
typedef decltype(functor()) result_type; typedef decltype(functor()) result_type;
return (new StoredFunctorCall0<result_type, Functor>(functor))->start(pool); return (new StoredFunctorCall0<result_type, Functor>(functor))->start(pool);
@ -380,7 +380,7 @@ auto run(QThreadPool *pool, Functor functor) -> typename QtPrivate::QEnableIf<!Q
template <typename Functor, typename Arg1> template <typename Functor, typename Arg1>
auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1) auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1))>>::type
{ {
typedef decltype(functor(arg1)) result_type; typedef decltype(functor(arg1)) result_type;
return (new StoredFunctorCall1<result_type, Functor, Arg1>(functor, arg1))->start(pool); return (new StoredFunctorCall1<result_type, Functor, Arg1>(functor, arg1))->start(pool);
@ -388,7 +388,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1)
template <typename Functor, typename Arg1, typename Arg2> template <typename Functor, typename Arg1, typename Arg2>
auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2) auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2))>>::type
{ {
typedef decltype(functor(arg1, arg2)) result_type; typedef decltype(functor(arg1, arg2)) result_type;
return (new StoredFunctorCall2<result_type, Functor, Arg1, Arg2>(functor, arg1, arg2))->start(pool); return (new StoredFunctorCall2<result_type, Functor, Arg1, Arg2>(functor, arg1, arg2))->start(pool);
@ -396,7 +396,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2)
template <typename Functor, typename Arg1, typename Arg2, typename Arg3> template <typename Functor, typename Arg1, typename Arg2, typename Arg3>
auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3))>>::type
{ {
typedef decltype(functor(arg1, arg2, arg3)) result_type; typedef decltype(functor(arg1, arg2, arg3)) result_type;
return (new StoredFunctorCall3<result_type, Functor, Arg1, Arg2, Arg3>(functor, arg1, arg2, arg3))->start(pool); return (new StoredFunctorCall3<result_type, Functor, Arg1, Arg2, Arg3>(functor, arg1, arg2, arg3))->start(pool);
@ -404,7 +404,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2,
template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4> template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4))>>::type
{ {
typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type;
return (new StoredFunctorCall4<result_type, Functor, Arg1, Arg2, Arg3, Arg4>(functor, arg1, arg2, arg3, arg4))->start(pool); return (new StoredFunctorCall4<result_type, Functor, Arg1, Arg2, Arg3, Arg4>(functor, arg1, arg2, arg3, arg4))->start(pool);
@ -412,7 +412,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2,
template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
-> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4, arg5))> >::Type -> typename std::enable_if<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1, arg2, arg3, arg4, arg5))>>::type
{ {
typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type;
return (new StoredFunctorCall5<result_type, Functor, Arg1, Arg2, Arg3, Arg4, Arg5>(functor, arg1, arg2, arg3, arg4, arg5))->start(pool); return (new StoredFunctorCall5<result_type, Functor, Arg1, Arg2, Arg3, Arg4, Arg5>(functor, arg1, arg2, arg3, arg4, arg5))->start(pool);

View File

@ -174,7 +174,7 @@ static inline bool qt_is_finite(float f)
// Unsigned overflow math // Unsigned overflow math
// //
namespace { namespace {
template <typename T> inline typename QtPrivate::QEnableIf<std::is_unsigned<T>::value, bool>::Type template <typename T> inline typename std::enable_if<std::is_unsigned<T>::value, bool>::type
add_overflow(T v1, T v2, T *r) add_overflow(T v1, T v2, T *r)
{ {
// unsigned additions are well-defined // unsigned additions are well-defined
@ -182,7 +182,7 @@ add_overflow(T v1, T v2, T *r)
return v1 > T(v1 + v2); return v1 > T(v1 + v2);
} }
template <typename T> inline typename QtPrivate::QEnableIf<std::is_unsigned<T>::value, bool>::Type template <typename T> inline typename std::enable_if<std::is_unsigned<T>::value, bool>::type
mul_overflow(T v1, T v2, T *r) mul_overflow(T v1, T v2, T *r)
{ {
// use the next biggest type // use the next biggest type

View File

@ -124,7 +124,7 @@ struct QTypeInfoQuery : public QTypeInfo<T>
// if QTypeInfo<T>::isRelocatable exists, use it // if QTypeInfo<T>::isRelocatable exists, use it
template <typename T> template <typename T>
struct QTypeInfoQuery<T, typename QtPrivate::QEnableIf<QTypeInfo<T>::isRelocatable || true>::Type> : public QTypeInfo<T> struct QTypeInfoQuery<T, typename std::enable_if<QTypeInfo<T>::isRelocatable || true>::type> : public QTypeInfo<T>
{}; {};
/*! /*!

View File

@ -365,7 +365,7 @@ Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaO
Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name); Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name);
template<typename T> template<typename T>
typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type typename std::enable_if<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::type
operator<<(QDebug dbg, T value) operator<<(QDebug dbg, T value)
{ {
const QMetaObject *obj = qt_getEnumMetaObject(value); const QMetaObject *obj = qt_getEnumMetaObject(value);
@ -374,9 +374,9 @@ operator<<(QDebug dbg, T value)
} }
template <class T> template <class T>
inline typename QtPrivate::QEnableIf< inline typename std::enable_if<
QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<QFlags<T> >::Value, QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<QFlags<T> >::Value,
QDebug>::Type QDebug>::type
qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags) qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags)
{ {
const QMetaObject *obj = qt_getEnumMetaObject(T()); const QMetaObject *obj = qt_getEnumMetaObject(T());
@ -385,9 +385,9 @@ qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags)
} }
template <class T> template <class T>
inline typename QtPrivate::QEnableIf< inline typename std::enable_if<
!QtPrivate::IsQEnumHelper<T>::Value && !QtPrivate::IsQEnumHelper<QFlags<T> >::Value, !QtPrivate::IsQEnumHelper<T>::Value && !QtPrivate::IsQEnumHelper<QFlags<T> >::Value,
QDebug>::Type QDebug>::type
qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags) qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags)
#else // !QT_NO_QOBJECT && !Q_QDOC #else // !QT_NO_QOBJECT && !Q_QDOC
template <class T> template <class T>
@ -402,7 +402,7 @@ template<typename T>
inline QDebug operator<<(QDebug debug, const QFlags<T> &flags) inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
{ {
// We have to use an indirection otherwise specialisation of some other overload of the // We have to use an indirection otherwise specialisation of some other overload of the
// operator<< the compiler would try to instantiate QFlags<T> for the QEnableIf // operator<< the compiler would try to instantiate QFlags<T> for the std::enable_if
return qt_QMetaEnum_flagDebugOperator_helper(debug, flags); return qt_QMetaEnum_flagDebugOperator_helper(debug, flags);
} }

View File

@ -1413,17 +1413,17 @@ namespace QtPrivate
static inline const QMetaObject *value() { return Q_NULLPTR; } static inline const QMetaObject *value() { return Q_NULLPTR; }
}; };
template<typename T> template<typename T>
struct MetaObjectForType<T*, typename QEnableIf<IsPointerToTypeDerivedFromQObject<T*>::Value>::Type> struct MetaObjectForType<T*, typename std::enable_if<IsPointerToTypeDerivedFromQObject<T*>::Value>::type>
{ {
static inline const QMetaObject *value() { return &T::staticMetaObject; } static inline const QMetaObject *value() { return &T::staticMetaObject; }
}; };
template<typename T> template<typename T>
struct MetaObjectForType<T, typename QEnableIf<IsGadgetHelper<T>::Value>::Type> struct MetaObjectForType<T, typename std::enable_if<IsGadgetHelper<T>::Value>::type>
{ {
static inline const QMetaObject *value() { return &T::staticMetaObject; } static inline const QMetaObject *value() { return &T::staticMetaObject; }
}; };
template<typename T> template<typename T>
struct MetaObjectForType<T, typename QEnableIf<IsQEnumHelper<T>::Value>::Type > struct MetaObjectForType<T, typename std::enable_if<IsQEnumHelper<T>::Value>::type >
{ {
static inline const QMetaObject *value() { return qt_getEnumMetaObject(T()); } static inline const QMetaObject *value() { return qt_getEnumMetaObject(T()); }
}; };
@ -2009,7 +2009,7 @@ struct SharedPointerMetaTypeIdHelper<SMART_POINTER<T>, true> \
}; \ }; \
template<typename T> \ template<typename T> \
struct MetaTypeSmartPointerHelper<SMART_POINTER<T> , \ struct MetaTypeSmartPointerHelper<SMART_POINTER<T> , \
typename QEnableIf<IsPointerToTypeDerivedFromQObject<T*>::Value >::Type> \ typename std::enable_if<IsPointerToTypeDerivedFromQObject<T*>::Value>::type> \
{ \ { \
static bool registerConverter(int id) \ static bool registerConverter(int id) \
{ \ { \

View File

@ -261,7 +261,7 @@ public:
//connect to a function pointer (not a member) //connect to a function pointer (not a member)
template <typename Func1, typename Func2> template <typename Func1, typename Func2>
static inline typename QtPrivate::QEnableIf<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0, QMetaObject::Connection>::Type static inline typename std::enable_if<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0, QMetaObject::Connection>::type
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
{ {
return connect(sender, signal, sender, slot, Qt::DirectConnection); return connect(sender, signal, sender, slot, Qt::DirectConnection);
@ -269,8 +269,8 @@ public:
//connect to a function pointer (not a member) //connect to a function pointer (not a member)
template <typename Func1, typename Func2> template <typename Func1, typename Func2>
static inline typename QtPrivate::QEnableIf<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0 && static inline typename std::enable_if<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0 &&
!QtPrivate::FunctionPointer<Func2>::IsPointerToMemberFunction, QMetaObject::Connection>::Type !QtPrivate::FunctionPointer<Func2>::IsPointerToMemberFunction, QMetaObject::Connection>::type
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
Qt::ConnectionType type = Qt::AutoConnection) Qt::ConnectionType type = Qt::AutoConnection)
{ {
@ -301,7 +301,7 @@ public:
//connect to a functor //connect to a functor
template <typename Func1, typename Func2> template <typename Func1, typename Func2>
static inline typename QtPrivate::QEnableIf<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::Type static inline typename std::enable_if<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::type
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
{ {
return connect(sender, signal, sender, slot, Qt::DirectConnection); return connect(sender, signal, sender, slot, Qt::DirectConnection);
@ -309,7 +309,7 @@ public:
//connect to a functor, with a "context" object defining in which event loop is going to be executed //connect to a functor, with a "context" object defining in which event loop is going to be executed
template <typename Func1, typename Func2> template <typename Func1, typename Func2>
static inline typename QtPrivate::QEnableIf<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::Type static inline typename std::enable_if<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::type
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
Qt::ConnectionType type = Qt::AutoConnection) Qt::ConnectionType type = Qt::AutoConnection)
{ {

View File

@ -118,30 +118,30 @@ public:
} }
// singleShot to a functor or function pointer (without context) // singleShot to a functor or function pointer (without context)
template <typename Duration, typename Func1> template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction && static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!std::is_same<const char*, Func1>::value, void>::Type !std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, Func1 slot) singleShot(Duration interval, Func1 slot)
{ {
singleShot(interval, defaultTypeFor(interval), nullptr, slot); singleShot(interval, defaultTypeFor(interval), nullptr, slot);
} }
template <typename Duration, typename Func1> template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction && static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!std::is_same<const char*, Func1>::value, void>::Type !std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, Qt::TimerType timerType, Func1 slot) singleShot(Duration interval, Qt::TimerType timerType, Func1 slot)
{ {
singleShot(interval, timerType, nullptr, slot); singleShot(interval, timerType, nullptr, slot);
} }
// singleShot to a functor or function pointer (with context) // singleShot to a functor or function pointer (with context)
template <typename Duration, typename Func1> template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction && static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!std::is_same<const char*, Func1>::value, void>::Type !std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, QObject *context, Func1 slot) singleShot(Duration interval, QObject *context, Func1 slot)
{ {
singleShot(interval, defaultTypeFor(interval), context, slot); singleShot(interval, defaultTypeFor(interval), context, slot);
} }
template <typename Duration, typename Func1> template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction && static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!std::is_same<const char*, Func1>::value, void>::Type !std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot) singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot)
{ {
//compilation error if the slot has arguments. //compilation error if the slot has arguments.

View File

@ -283,7 +283,7 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndRelaxed(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndAndRelaxed(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
// implement fetchAndAnd on top of testAndSet // implement fetchAndAnd on top of testAndSet
T tmp = BaseClass::load(_q_value); T tmp = BaseClass::load(_q_value);
@ -294,7 +294,7 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndAcquire(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndAndAcquire(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
T tmp = BaseClass::fetchAndAndRelaxed(_q_value, operand); T tmp = BaseClass::fetchAndAndRelaxed(_q_value, operand);
BaseClass::acquireMemoryFence(_q_value); BaseClass::acquireMemoryFence(_q_value);
@ -302,21 +302,21 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndRelease(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndAndRelease(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
BaseClass::releaseMemoryFence(_q_value); BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndAndRelaxed(_q_value, operand); return BaseClass::fetchAndAndRelaxed(_q_value, operand);
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndOrdered(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndAndOrdered(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
BaseClass::orderedMemoryFence(_q_value); BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndAndRelaxed(_q_value, operand); return BaseClass::fetchAndAndRelaxed(_q_value, operand);
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrRelaxed(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndOrRelaxed(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
// implement fetchAndOr on top of testAndSet // implement fetchAndOr on top of testAndSet
T tmp = BaseClass::load(_q_value); T tmp = BaseClass::load(_q_value);
@ -327,7 +327,7 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrAcquire(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndOrAcquire(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
T tmp = BaseClass::fetchAndOrRelaxed(_q_value, operand); T tmp = BaseClass::fetchAndOrRelaxed(_q_value, operand);
BaseClass::acquireMemoryFence(_q_value); BaseClass::acquireMemoryFence(_q_value);
@ -335,21 +335,21 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrRelease(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndOrRelease(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
BaseClass::releaseMemoryFence(_q_value); BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndOrRelaxed(_q_value, operand); return BaseClass::fetchAndOrRelaxed(_q_value, operand);
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrOrdered(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndOrOrdered(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
BaseClass::orderedMemoryFence(_q_value); BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndOrRelaxed(_q_value, operand); return BaseClass::fetchAndOrRelaxed(_q_value, operand);
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorRelaxed(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndXorRelaxed(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
// implement fetchAndXor on top of testAndSet // implement fetchAndXor on top of testAndSet
T tmp = BaseClass::load(_q_value); T tmp = BaseClass::load(_q_value);
@ -360,7 +360,7 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorAcquire(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndXorAcquire(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
T tmp = BaseClass::fetchAndXorRelaxed(_q_value, operand); T tmp = BaseClass::fetchAndXorRelaxed(_q_value, operand);
BaseClass::acquireMemoryFence(_q_value); BaseClass::acquireMemoryFence(_q_value);
@ -368,14 +368,14 @@ template <typename BaseClass> struct QGenericAtomicOps
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorRelease(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndXorRelease(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
BaseClass::releaseMemoryFence(_q_value); BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndXorRelaxed(_q_value, operand); return BaseClass::fetchAndXorRelaxed(_q_value, operand);
} }
template <typename T> static Q_ALWAYS_INLINE template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorOrdered(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW T fetchAndXorOrdered(T &_q_value, typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type operand) Q_DECL_NOTHROW
{ {
BaseClass::orderedMemoryFence(_q_value); BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndXorRelaxed(_q_value, operand); return BaseClass::fetchAndXorRelaxed(_q_value, operand);

View File

@ -211,25 +211,25 @@ static void clear_thread_data()
} }
template <typename T> template <typename T>
static typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, Qt::HANDLE>::Type to_HANDLE(T id) static typename std::enable_if<QTypeInfo<T>::isIntegral, Qt::HANDLE>::type to_HANDLE(T id)
{ {
return reinterpret_cast<Qt::HANDLE>(static_cast<intptr_t>(id)); return reinterpret_cast<Qt::HANDLE>(static_cast<intptr_t>(id));
} }
template <typename T> template <typename T>
static typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type from_HANDLE(Qt::HANDLE id) static typename std::enable_if<QTypeInfo<T>::isIntegral, T>::type from_HANDLE(Qt::HANDLE id)
{ {
return static_cast<T>(reinterpret_cast<intptr_t>(id)); return static_cast<T>(reinterpret_cast<intptr_t>(id));
} }
template <typename T> template <typename T>
static typename QtPrivate::QEnableIf<QTypeInfo<T>::isPointer, Qt::HANDLE>::Type to_HANDLE(T id) static typename std::enable_if<QTypeInfo<T>::isPointer, Qt::HANDLE>::type to_HANDLE(T id)
{ {
return id; return id;
} }
template <typename T> template <typename T>
static typename QtPrivate::QEnableIf<QTypeInfo<T>::isPointer, T>::Type from_HANDLE(Qt::HANDLE id) static typename std::enable_if<QTypeInfo<T>::isPointer, T>::type from_HANDLE(Qt::HANDLE id)
{ {
return static_cast<T>(id); return static_cast<T>(id);
} }

View File

@ -411,18 +411,18 @@ struct QArrayOpsSelector
template <class T> template <class T>
struct QArrayOpsSelector<T, struct QArrayOpsSelector<T,
typename QEnableIf< typename std::enable_if<
!QTypeInfo<T>::isComplex && !QTypeInfo<T>::isStatic !QTypeInfo<T>::isComplex && !QTypeInfo<T>::isStatic
>::Type> >::type>
{ {
typedef QPodArrayOps<T> Type; typedef QPodArrayOps<T> Type;
}; };
template <class T> template <class T>
struct QArrayOpsSelector<T, struct QArrayOpsSelector<T,
typename QEnableIf< typename std::enable_if<
QTypeInfo<T>::isComplex && !QTypeInfo<T>::isStatic QTypeInfo<T>::isComplex && !QTypeInfo<T>::isStatic
>::Type> >::type>
{ {
typedef QMovableArrayOps<T> Type; typedef QMovableArrayOps<T> Type;
}; };

View File

@ -99,10 +99,10 @@ struct Q_CORE_EXPORT QMapNodeBase
void setParent(QMapNodeBase *pp) { p = (p & Mask) | quintptr(pp); } void setParent(QMapNodeBase *pp) { p = (p & Mask) | quintptr(pp); }
template <typename T> template <typename T>
static typename QtPrivate::QEnableIf<QTypeInfo<T>::isComplex>::Type static typename std::enable_if<QTypeInfo<T>::isComplex>::type
callDestructorIfNecessary(T &t) Q_DECL_NOTHROW { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning callDestructorIfNecessary(T &t) Q_DECL_NOTHROW { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning
template <typename T> template <typename T>
static typename QtPrivate::QEnableIf<!QTypeInfo<T>::isComplex>::Type static typename std::enable_if<!QTypeInfo<T>::isComplex>::type
callDestructorIfNecessary(T &) Q_DECL_NOTHROW {} callDestructorIfNecessary(T &) Q_DECL_NOTHROW {}
}; };

View File

@ -974,13 +974,13 @@ qobject_cast(const QWeakPointer<T> &src)
} }
template<typename T> template<typename T>
QWeakPointer<typename QtPrivate::QEnableIf<QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value, T>::Type> QWeakPointer<typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value, T>::type>
qWeakPointerFromVariant(const QVariant &variant) qWeakPointerFromVariant(const QVariant &variant)
{ {
return QWeakPointer<T>(qobject_cast<T*>(QtSharedPointer::weakPointerFromVariant_internal(variant).data())); return QWeakPointer<T>(qobject_cast<T*>(QtSharedPointer::weakPointerFromVariant_internal(variant).data()));
} }
template<typename T> template<typename T>
QSharedPointer<typename QtPrivate::QEnableIf<QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value, T>::Type> QSharedPointer<typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value, T>::type>
qSharedPointerFromVariant(const QVariant &variant) qSharedPointerFromVariant(const QVariant &variant)
{ {
return qSharedPointerObjectCast<T>(QtSharedPointer::sharedPointerFromVariant_internal(variant)); return qSharedPointerObjectCast<T>(QtSharedPointer::sharedPointerFromVariant_internal(variant));

View File

@ -108,9 +108,9 @@ union qt_sockaddr {
namespace { namespace {
namespace SetSALen { namespace SetSALen {
template <typename T> void set(T *sa, typename QtPrivate::QEnableIf<(&T::sa_len, true), QT_SOCKLEN_T>::Type len) template <typename T> void set(T *sa, typename std::enable_if<(&T::sa_len, true), QT_SOCKLEN_T>::type len)
{ sa->sa_len = len; } { sa->sa_len = len; }
template <typename T> void set(T *sin6, typename QtPrivate::QEnableIf<(&T::sin6_len, true), QT_SOCKLEN_T>::Type len) template <typename T> void set(T *sin6, typename std::enable_if<(&T::sin6_len, true), QT_SOCKLEN_T>::type len)
{ sin6->sin6_len = len; } { sin6->sin6_len = len; }
template <typename T> void set(T *, ...) {} template <typename T> void set(T *, ...) {}
} }

View File

@ -240,14 +240,14 @@ namespace QTest
namespace Internal { namespace Internal {
template<typename T> // Output registered enums template<typename T> // Output registered enums
inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(T e) inline typename std::enable_if<QtPrivate::IsQEnumHelper<T>::Value, char*>::type toString(T e)
{ {
QMetaEnum me = QMetaEnum::fromType<T>(); QMetaEnum me = QMetaEnum::fromType<T>();
return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes
} }
template <typename T> // Fallback template <typename T> // Fallback
inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(const T &) inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value, char*>::type toString(const T &)
{ {
return Q_NULLPTR; return Q_NULLPTR;
} }

View File

@ -98,8 +98,8 @@ public:
#else #else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context) // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1> template<class Obj, typename Func1>
inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0) addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
{ {
QAction *result = addAction(text); QAction *result = addAction(text);
@ -126,8 +126,8 @@ public:
} }
// addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context) // addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1> template<class Obj, typename Func1>
inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0) addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
{ {
QAction *result = addAction(actionIcon, text); QAction *result = addAction(actionIcon, text);

View File

@ -116,8 +116,8 @@ public:
#else #else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context) // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1> template<class Obj, typename Func1>
inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QString &text, const Obj *object, Func1 slot) addAction(const QString &text, const Obj *object, Func1 slot)
{ {
QAction *result = addAction(text); QAction *result = addAction(text);
@ -134,8 +134,8 @@ public:
} }
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context) // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1> template<class Obj, typename Func1>
inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot) addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
{ {
QAction *result = addAction(actionIcon, text); QAction *result = addAction(actionIcon, text);