summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobjectdefs_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qobjectdefs_impl.h')
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 1452e720ad..4f44d9204e 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -45,7 +46,10 @@
#error Do not include qobjectdefs_impl.h directly
#endif
-QT_BEGIN_HEADER
+#if 0
+#pragma qt_sync_skip_header_check
+#pragma qt_sync_stop_processing
+#endif
QT_BEGIN_NAMESPACE
@@ -90,7 +94,7 @@ namespace QtPrivate {
template <typename T>
struct ApplyReturnValue {
void *data;
- ApplyReturnValue(void *data_) : data(data_) {}
+ explicit ApplyReturnValue(void *data_) : data(data_) {}
};
template<typename T, typename U>
void operator,(const T &value, const ApplyReturnValue<U> &container) {
@@ -594,13 +598,44 @@ namespace QtPrivate {
enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
&& CheckCompatibleArguments<List<Tail1...>, List<Tail2...>>::value };
};
+#endif
+
+#if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
+ /*
+ Find the maximum number of arguments a functor object can take and be still compatible with
+ the arguments from the signal.
+ Value is the number of arguments, or -1 if nothing matches.
+ */
+ template <typename Functor, typename ArgList> struct ComputeFunctorArgumentCount;
+
+ template <typename Functor, typename ArgList, bool Done> struct ComputeFunctorArgumentCountHelper
+ { enum { Value = -1 }; };
+ template <typename Functor, typename First, typename... ArgList>
+ struct ComputeFunctorArgumentCountHelper<Functor, List<First, ArgList...>, false>
+ : ComputeFunctorArgumentCount<Functor,
+ typename List_Left<List<First, ArgList...>, sizeof...(ArgList)>::Value> {};
+
+ template <typename Functor, typename... ArgList> struct ComputeFunctorArgumentCount<Functor, List<ArgList...>>
+ {
+ template <typename D> static D dummy();
+ template <typename F> static auto test(F f) -> decltype(((f.operator()((dummy<ArgList>())...)), int()));
+ static char test(...);
+ enum {
+ Ok = sizeof(test(dummy<Functor>())) == sizeof(int),
+ Value = Ok ? sizeof...(ArgList) : int(ComputeFunctorArgumentCountHelper<Functor, List<ArgList...>, Ok>::Value)
+ };
+ };
+ /* get the return type of a functor, given the signal argument list */
+ template <typename Functor, typename ArgList> struct FunctorReturnType;
+ template <typename Functor, typename ... ArgList> struct FunctorReturnType<Functor, List<ArgList...>> {
+ template <typename D> static D dummy();
+ typedef decltype(dummy<Functor>().operator()((dummy<ArgList>())...)) Value;
+ };
#endif
-}
+}
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif