summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentfunctionwrappers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/concurrent/qtconcurrentfunctionwrappers.h')
-rw-r--r--src/concurrent/qtconcurrentfunctionwrappers.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentfunctionwrappers.h b/src/concurrent/qtconcurrentfunctionwrappers.h
index 194d020fb28..59d2d61af68 100644
--- a/src/concurrent/qtconcurrentfunctionwrappers.h
+++ b/src/concurrent/qtconcurrentfunctionwrappers.h
@@ -41,6 +41,7 @@
#define QTCONCURRENT_FUNCTIONWRAPPERS_H
#include <QtConcurrent/qtconcurrentcompilertest.h>
+#include <QtCore/qfuture.h>
#include <QtCore/QStringList>
#include <tuple>
@@ -143,6 +144,50 @@ struct ReduceResultType<T(C::*)(U) noexcept>
};
#endif
+template<class T, class Enable = void>
+struct hasCallOperator : std::false_type
+{
+};
+
+template<class T>
+struct hasCallOperator<T, std::void_t<decltype(&T::operator())>> : std::true_type
+{
+};
+
+template<class T, class Enable = void>
+struct isIterator : std::false_type
+{
+};
+
+template<class T>
+struct isIterator<T, std::void_t<typename std::iterator_traits<T>::value_type>> : std::true_type
+{
+};
+
+template <class Callable, class Sequence>
+using isInvocable = std::is_invocable<Callable, typename std::decay_t<Sequence>::value_type>;
+
+template<class Callable, class Enable = void>
+struct ReduceResultTypeHelper
+{
+};
+
+template <class Callable>
+struct ReduceResultTypeHelper<Callable,
+ typename std::enable_if_t<std::is_function_v<std::remove_pointer_t<std::decay_t<Callable>>>
+ || std::is_member_function_pointer_v<std::decay_t<Callable>>>>
+{
+ using type = typename QtPrivate::ReduceResultType<std::decay_t<Callable>>::ResultType;
+};
+
+template <class Callable>
+struct ReduceResultTypeHelper<Callable,
+ typename std::enable_if_t<!std::is_function_v<std::remove_pointer_t<std::decay_t<Callable>>>
+ && hasCallOperator<std::decay_t<Callable>>::value>>
+{
+ using type = std::decay_t<typename QtPrivate::ArgResolver<Callable>::First>;
+};
+
// -- MapSequenceResultType
template <class InputSequence, class MapFunctor>