// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTCONCURRENT_FUNCTIONWRAPPERS_H #define QTCONCURRENT_FUNCTIONWRAPPERS_H #include #include #include #include #if !defined(QT_NO_CONCURRENT) || defined(Q_CLANG_QDOC) QT_BEGIN_NAMESPACE namespace QtPrivate { struct PushBackWrapper { template inline void operator()(C &c, const U &u) const { return c.push_back(u); } template inline void operator()(C &c, U &&u) const { return c.push_back(u); } }; // -- MapResultType template struct Argument { using Type = void; }; template struct Argument>::type> { using Type = std::decay_t().begin())>; }; template struct Argument>::type> { using Type = std::decay_t())>; }; template using ArgumentType = typename Argument::Type; template struct MapResult { static_assert(std::is_invocable_v, ArgumentType>, "It's not possible to invoke the function with passed argument."); using Type = std::invoke_result_t, ArgumentType>; }; template using MapResultType = typename MapResult::Type; // -- ReduceResultType template struct ReduceResultType; template struct ReduceResultType { using ResultType = U; }; template struct ReduceResultType { using ResultType = C; }; template struct ReduceResultType> { using ResultType = U; }; template struct ReduceResultType { using ResultType = typename std::tuple_element<0, std::tuple>::type; }; template struct ReduceResultType { using ResultType = U; }; template struct ReduceResultType { using ResultType = C; }; template inline constexpr bool hasCallOperator_v = false; template inline constexpr bool hasCallOperator_v> = true; template inline constexpr bool isIterator_v = false; template inline constexpr bool isIterator_v::value_type>> = true; template using isInvocable = std::is_invocable::value_type>; template inline constexpr bool isInitialValueCompatible_v = std::conjunction_v< std::is_convertible, std::negation, QtConcurrent::ReduceOption>>>; template struct ReduceResultTypeHelper { }; template struct ReduceResultTypeHelper>> || std::is_member_function_pointer_v>>> { using type = typename QtPrivate::ReduceResultType>::ResultType; }; template struct ReduceResultTypeHelper>> && hasCallOperator_v>>> { using type = std::decay_t::First>; }; // -- MapSequenceResultType template struct MapSequenceResultType { static_assert(std::is_same_v>, "Couldn't deduce the output sequence type, you must specify it explicitly."); typedef InputSequence ResultType; }; #ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS template