GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
map.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_MAP_H
22 #define GRPPI_MAP_H
23 
24 #include <utility>
25 
27 #include "common/iterator_traits.h"
28 
29 namespace grppi {
30 
51 template<typename Execution, typename ...InputIterators, typename InputIt,
52  typename OutputIt, typename Transformer,
53  requires_iterators<InputIterators...> = 0,
54  requires_iterator<InputIt> = 0,
55  requires_iterator<OutputIt> = 0>
56 void map(const Execution & ex, std::tuple<InputIterators...> firsts,
57  InputIt last, OutputIt first_out,
58  Transformer transform_op)
59 {
60  static_assert(supports_map<Execution>(),
61  "map not supported on execution type");
62  ex.map(firsts, first_out,
63  std::distance(std::get<0>(firsts),last), transform_op);
64 }
65 
66 
67 
79 template<typename Execution, typename ...InputIterators,
80  typename OutputIt, typename Transformer,
81  requires_iterators<InputIterators...> = 0,
83 void map(const Execution & ex, std::tuple<InputIterators...> firsts,
84  std::size_t range, OutputIt first_out,
85  Transformer transformer_op)
86 {
87  static_assert(supports_map<Execution>(),
88  "map not supported on execution type");
89  ex.map(firsts, first_out, range, transformer_op);
90 }
91 
103 template <typename Execution, typename InputIt, typename OutputIt,
104  typename Transformer,
107 void map(const Execution & ex,
108  InputIt first, InputIt last, OutputIt first_out,
109  Transformer transform_op)
110 {
111  static_assert(supports_map<Execution>(),
112  "map not supported on execution type");
113  ex.map(make_tuple(first), first_out,
114  std::distance(first, last), transform_op);
115 }
116 
130 template <typename Execution, typename InputIt, typename OutputIt, typename Transformer,
131  typename ... OtherInputIts,
132  requires_iterator<InputIt> = 0,
134 [[deprecated("This version of the interface is deprecated.\n"
135  "If you want to use multiple inputs, use a tuple instead.")]]
136 void map(const Execution & ex,
137  InputIt first, InputIt last, OutputIt first_out,
138  Transformer transform_op,
139  OtherInputIts ... other_firsts)
140 {
141  static_assert(supports_map<Execution>(),
142  "map not supported on execution type");
143  ex.map(make_tuple(first,other_firsts...), first_out,
144  std::distance(first,last), transform_op);
145 }
146 
151 }
152 
153 #endif
Definition: callable_traits.h:26
std::enable_if_t< are_iterators< T... >, int > requires_iterators
Definition: iterator_traits.h:64
std::enable_if_t< is_iterator< T >, int > requires_iterator
Definition: iterator_traits.h:58
void map(const Execution &ex, std::tuple< InputIterators... > firsts, InputIt last, OutputIt first_out, Transformer transform_op)
Invoke Map pattern on a data sequence.
Definition: map.h:56