23 template<
class Executor,
class T>
class Graph {
31 auto middle = p(first, last);
60 template<
class I,
class S,
class T,
class Fun = std::plus<>>
63 traits::is_input_iterator_v<I> &&
64 traits::is_sentinel_for_v<S, I> &&
65 std::is_same_v<traits::iter_value_t<I>,
T> &&
66 traits::is_indirectly_binary_invocable_v<Fun, I, I> &&
67 std::is_copy_constructible_v<Fun>
69 )
static constexpr T run(
I first,
S last,
T init,
Fun op) {
70 return std::accumulate(first, last, std::move(init), std::move(op));
88 template<
class E,
class P,
class I,
class S,
class T,
class Fun = std::plus<>>
91 traits::is_executor_v<E> &&
92 traits::is_partitioner_v<P, I, S> &&
93 traits::is_input_iterator_v<I> &&
94 traits::is_sentinel_for_v<S, I> &&
95 std::is_same_v<traits::iter_value_t<I>,
T> &&
96 traits::is_indirectly_binary_invocable_v<Fun, I, I> &&
97 std::is_copy_constructible_v<Fun>
100 if constexpr(traits::is_inline_executor_v<E>) {
101 co_return run(first, last,
i, f);
103 co_return co_await Graph<E, T>(executor).launch(p, first, last,
i, f);
A partitioner is a light callable object that takes a pair of iterators and returns the middle of the...
Binary algorithm overloads.
Definition BinaryAlgorithm.hpp:26
Async< T > launch(P p, I first, S last, T i, Fun f)
Definition Reduce.hpp:30
Executor mExecutor
Definition Reduce.hpp:25
Graph(const Executor &executor)
Definition Reduce.hpp:28
Functor representing the overloads for the reduce function.
Definition Reduce.hpp:19
static constexpr T run(I first, S last, T init, Fun op)
Complete overload of the reduce algorithm.
Definition Reduce.hpp:69
static Async< T > run(const E &executor, P p, I first, S last, T i, Fun f=Fun())
Complete overload of the reduce algorithm.
Definition Reduce.hpp:99
typename iter_difference< T >::type iter_difference_t
A C++17 type trait equivalent to the C++20 iter_difference concept.
Definition iter_difference.hpp:85
Definition Application.hpp:19
auto with(Executor executor)
Definition ExecutionContext.hpp:546
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
constexpr ReduceAlgorithmFunctor reduce
Sums up (or accumulate with a custom function) a range of elements, except out of order.
Definition Reduce.hpp:110
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25