GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
reduce.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_REDUCE_H
22 #define GRPPI_REDUCE_H
23 
24 #include <utility>
25 
26 #include "common/iterator_traits.h"
28 
29 namespace grppi {
30 
53 template <typename Execution, typename InputIt, typename Result, typename Combiner,
54  requires_iterator<InputIt> = 0>
55 auto reduce(const Execution & ex,
56  InputIt first, std::size_t size,
57  Result && identity,
58  Combiner && combine_op)
59 {
60  static_assert(supports_reduce<Execution>(),
61  "reduce not supported on execution type");
62  return ex.reduce(first, size,
63  std::forward<Result>(identity), std::forward<Combiner>(combine_op));
64 }
65 
80 template <typename Execution, typename InputIt, typename Result, typename Combiner,
81  requires_iterator<InputIt> = 0>
82 auto reduce(const Execution & ex,
83  InputIt first, InputIt last,
84  Result && identity,
85  Combiner && combine_op)
86 {
87  static_assert(supports_reduce<Execution>(),
88  "reduce not supported on execution type");
89  return ex.reduce(first, std::distance(first,last),
90  std::forward<Result>(identity), std::forward<Combiner>(combine_op));
91 }
92 
97 }
98 
99 #endif
Definition: callable_traits.h:26
auto reduce(const Execution &ex, InputIt first, std::size_t size, Result &&identity, Combiner &&combine_op)
Invoke Reduce pattern with identity value on a data sequence with sequential execution.
Definition: reduce.h:55