diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:46:57 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:49:28 +0100 |
commit | 76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch) | |
tree | f165b7bc319548fb0082365411a871028f92e89e /src/corelib/kernel/qobjectdefs_impl.h | |
parent | 27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff) | |
parent | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Conflicts:
src/gui/text/qfontdatabase.cpp
src/gui/text/qharfbuzz_copy_p.h
src/widgets/kernel/qapplication.cpp
src/widgets/kernel/qcoreapplication.cpp
Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'src/corelib/kernel/qobjectdefs_impl.h')
-rw-r--r-- | src/corelib/kernel/qobjectdefs_impl.h | 45 |
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 |