diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 7f3720df1f..53c6de654f 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -302,7 +302,7 @@ public: types = QtPrivate::ConnectionTypes::types(); return connectImpl(sender, reinterpret_cast(&signal), context, nullptr, - new QtPrivate::QFunctorSlotObject::Value, typename SignalType::ReturnType>(std::move(slot)), type, types, &SignalType::Object::staticMetaObject); diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 8a9254a66d..3951c79fb3 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -29,17 +29,20 @@ namespace QtPrivate { the list composed of the first N element of the list */ // With variadic template, lists are represented using a variadic template argument instead of the lisp way - template struct List {}; - template struct List { typedef Head Car; typedef List Cdr; }; + template struct List { static constexpr size_t size = sizeof...(Ts); }; + template struct SizeOfList { static constexpr size_t value = 1; }; + template<> struct SizeOfList> { static constexpr size_t value = 0; }; + template struct SizeOfList> { static constexpr size_t value = List::size; }; + template struct List { + static constexpr size_t size = 1 + sizeof...(Tail); + typedef Head Car; typedef List Cdr; + }; template struct List_Append; template struct List_Append, List> { typedef List Value; }; template struct List_Left { typedef typename List_Append,typename List_Left::Value>::Value Value; }; template struct List_Left { typedef List<> Value; }; - // List_Select returns (via typedef Value) the Nth element of the list L - template struct List_Select { typedef typename List_Select::Value Value; }; - template struct List_Select { typedef typename L::Car Value; }; /* trick to set the return value of a slot that works even if the signal or the slot returns void @@ -418,11 +421,10 @@ namespace QtPrivate { explicit QSlotObject(Func f) : QSlotObjectBase(&impl), function(f) {} }; // implementation of QSlotObjectBase for which the slot is a functor (or lambda) - // N is the number of arguments // Args and R are the List of arguments and the return type of the signal to which the slot is connected. - template class QFunctorSlotObject : public QSlotObjectBase + template class QFunctorSlotObject : public QSlotObjectBase { - typedef QtPrivate::Functor FuncType; + using FuncType = QtPrivate::Functor; Func function; static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret) { @@ -449,7 +451,7 @@ namespace QtPrivate { typename QtPrivate::FunctionPointer::ReturnType>; template - using QFunctorSlotObjectWithNoArgs = QFunctorSlotObject, R>; + using QFunctorSlotObjectWithNoArgs = QFunctorSlotObject, R>; template using QFunctorSlotObjectWithNoArgsImplicitReturn = QFunctorSlotObjectWithNoArgs::ReturnType>; @@ -508,8 +510,7 @@ namespace QtPrivate { constexpr int MatchingArgumentCount = QtPrivate::countMatchingArguments(); using ActualArguments = typename QtPrivate::List_Left::Value; - return new QtPrivate::QFunctorSlotObject(std::move(func)); + return new QtPrivate::QFunctorSlotObject(std::move(func)); } } diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 5599b60bd7..a58eafa7d3 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -121,8 +121,7 @@ public: static_assert(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments."); singleShotImpl(interval, timerType, context, - new QtPrivate::QFunctorSlotObject::Value, void>(std::move(slot))); + new QtPrivate::QFunctorSlotObject, void>(std::move(slot))); } template