Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
_flow_graph_nodes_deduction.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2020 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef __TBB_flow_graph_nodes_deduction_H
18 #define __TBB_flow_graph_nodes_deduction_H
19 
20 #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
21 
22 namespace tbb {
23 namespace flow {
24 namespace interface11 {
25 
26 template <typename Input, typename Output>
27 struct declare_body_types {
28  using input_type = Input;
29  using output_type = Output;
30 };
31 
32 struct NoInputBody {};
33 
34 template <typename Output>
35 struct declare_body_types<NoInputBody, Output> {
36  using output_type = Output;
37 };
38 
39 template <typename T> struct body_types;
40 
41 template <typename T, typename Input, typename Output>
42 struct body_types<Output (T::*)(const Input&) const> : declare_body_types<Input, Output> {};
43 
44 template <typename T, typename Input, typename Output>
45 struct body_types<Output (T::*)(const Input&)> : declare_body_types<Input, Output> {};
46 
47 template <typename T, typename Input, typename Output>
48 struct body_types<Output (T::*)(Input&) const> : declare_body_types<Input, Output> {};
49 
50 template <typename T, typename Input, typename Output>
51 struct body_types<Output (T::*)(Input&)> : declare_body_types<Input, Output> {};
52 
53 template <typename Input, typename Output>
54 struct body_types<Output (*)(Input&)> : declare_body_types<Input, Output> {};
55 
56 template <typename Input, typename Output>
57 struct body_types<Output (*)(const Input&)> : declare_body_types<Input, Output> {};
58 
59 template <typename T, typename Output>
60 struct body_types<Output (T::*)(flow_control&) const> : declare_body_types<NoInputBody, Output> {};
61 
62 template <typename T, typename Output>
63 struct body_types<Output (T::*)(flow_control&)> : declare_body_types<NoInputBody, Output> {};
64 
65 template <typename Output>
66 struct body_types<Output (*)(flow_control&)> : declare_body_types<NoInputBody, Output> {};
67 
68 template <typename Body>
69 using input_t = typename body_types<Body>::input_type;
70 
71 template <typename Body>
72 using output_t = typename body_types<Body>::output_type;
73 
74 template <typename T, typename Input, typename Output>
75 auto decide_on_operator_overload(Output (T::*name)(const Input&) const)->decltype(name);
76 
77 template <typename T, typename Input, typename Output>
78 auto decide_on_operator_overload(Output (T::*name)(const Input&))->decltype(name);
79 
80 template <typename T, typename Input, typename Output>
81 auto decide_on_operator_overload(Output (T::*name)(Input&) const)->decltype(name);
82 
83 template <typename T, typename Input, typename Output>
84 auto decide_on_operator_overload(Output (T::*name)(Input&))->decltype(name);
85 
86 template <typename Input, typename Output>
87 auto decide_on_operator_overload(Output (*name)(const Input&))->decltype(name);
88 
89 template <typename Input, typename Output>
90 auto decide_on_operator_overload(Output (*name)(Input&))->decltype(name);
91 
92 template <typename Body>
93 decltype(decide_on_operator_overload(&Body::operator())) decide_on_callable_type(int);
94 
95 template <typename Body>
96 decltype(decide_on_operator_overload(std::declval<Body>())) decide_on_callable_type(...);
97 
98 // Deduction guides for Flow Graph nodes
99 #if TBB_USE_SOURCE_NODE_AS_ALIAS
100 #if TBB_DEPRECATED_INPUT_NODE_BODY
101 template <typename GraphOrSet, typename Body>
102 source_node(GraphOrSet&&, Body)
103 ->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
104 #else
105 template <typename GraphOrSet, typename Body>
106 source_node(GraphOrSet&&, Body)
107 ->source_node<output_t<decltype(decide_on_callable_type<Body>(0))>>;
108 #endif // TBB_DEPRECATED_INPUT_NODE_BODY
109 #else
110 template <typename GraphOrSet, typename Body>
111 source_node(GraphOrSet&&, Body, bool = true)
112 ->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
113 #endif
114 
115 #if TBB_DEPRECATED_INPUT_NODE_BODY
116 template <typename GraphOrSet, typename Body>
117 input_node(GraphOrSet&&, Body, bool = true)
118 ->input_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
119 #else
120 template <typename GraphOrSet, typename Body>
121 input_node(GraphOrSet&&, Body)
122 ->input_node<output_t<decltype(decide_on_callable_type<Body>(0))>>;
123 #endif
124 
125 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
126 
127 template <typename NodeSet>
128 struct decide_on_set;
129 
130 template <typename Node, typename... Nodes>
131 struct decide_on_set<node_set<internal::order::following, Node, Nodes...>> {
132  using type = typename Node::output_type;
133 };
134 
135 template <typename Node, typename... Nodes>
136 struct decide_on_set<node_set<internal::order::preceding, Node, Nodes...>> {
137  using type = typename Node::input_type;
138 };
139 
140 template <typename NodeSet>
141 using decide_on_set_t = typename decide_on_set<std::decay_t<NodeSet>>::type;
142 
143 template <typename NodeSet>
144 broadcast_node(const NodeSet&)
145 ->broadcast_node<decide_on_set_t<NodeSet>>;
146 
147 template <typename NodeSet>
148 buffer_node(const NodeSet&)
149 ->buffer_node<decide_on_set_t<NodeSet>>;
150 
151 template <typename NodeSet>
152 queue_node(const NodeSet&)
153 ->queue_node<decide_on_set_t<NodeSet>>;
154 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
155 
156 template <typename GraphOrProxy, typename Sequencer>
157 sequencer_node(GraphOrProxy&&, Sequencer)
158 ->sequencer_node<input_t<decltype(decide_on_callable_type<Sequencer>(0))>>;
159 
160 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
161 template <typename NodeSet, typename Compare>
162 priority_queue_node(const NodeSet&, const Compare&)
163 ->priority_queue_node<decide_on_set_t<NodeSet>, Compare>;
164 
165 template <typename NodeSet>
166 priority_queue_node(const NodeSet&)
167 ->priority_queue_node<decide_on_set_t<NodeSet>, std::less<decide_on_set_t<NodeSet>>>;
168 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
169 
170 template <typename Key>
171 struct join_key {
172  using type = Key;
173 };
174 
175 template <typename T>
176 struct join_key<const T&> {
177  using type = T&;
178 };
179 
180 template <typename Key>
181 using join_key_t = typename join_key<Key>::type;
182 
183 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
184 template <typename Policy, typename... Predecessors>
185 join_node(const node_set<internal::order::following, Predecessors...>&, Policy)
186 ->join_node<std::tuple<typename Predecessors::output_type...>,
187  Policy>;
188 
189 template <typename Policy, typename Successor, typename... Successors>
190 join_node(const node_set<internal::order::preceding, Successor, Successors...>&, Policy)
191 ->join_node<typename Successor::input_type, Policy>;
192 
193 template <typename... Predecessors>
194 join_node(const node_set<internal::order::following, Predecessors...>)
195 ->join_node<std::tuple<typename Predecessors::output_type...>,
196  queueing>;
197 
198 template <typename Successor, typename... Successors>
199 join_node(const node_set<internal::order::preceding, Successor, Successors...>)
200 ->join_node<typename Successor::input_type, queueing>;
201 #endif
202 
203 template <typename GraphOrProxy, typename Body, typename... Bodies>
204 join_node(GraphOrProxy&&, Body, Bodies...)
205 ->join_node<std::tuple<input_t<decltype(decide_on_callable_type<Body>(0))>,
206  input_t<decltype(decide_on_callable_type<Bodies>(0))>...>,
207  key_matching<join_key_t<output_t<decltype(decide_on_callable_type<Body>(0))>>>>;
208 
209 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
210 template <typename... Predecessors>
211 indexer_node(const node_set<internal::order::following, Predecessors...>&)
212 ->indexer_node<typename Predecessors::output_type...>;
213 #endif
214 
215 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
216 template <typename NodeSet>
217 limiter_node(const NodeSet&, size_t)
218 ->limiter_node<decide_on_set_t<NodeSet>>;
219 
220 template <typename Predecessor, typename... Predecessors>
221 split_node(const node_set<internal::order::following, Predecessor, Predecessors...>&)
222 ->split_node<typename Predecessor::output_type>;
223 
224 template <typename... Successors>
225 split_node(const node_set<internal::order::preceding, Successors...>&)
226 ->split_node<std::tuple<typename Successors::input_type...>>;
227 
228 #endif
229 
230 template <typename GraphOrSet, typename Body, typename Policy>
231 function_node(GraphOrSet&&,
232  size_t, Body,
234 ->function_node<input_t<decltype(decide_on_callable_type<Body>(0))>,
235  output_t<decltype(decide_on_callable_type<Body>(0))>,
236  Policy>;
237 
238 template <typename GraphOrSet, typename Body>
239 function_node(GraphOrSet&&, size_t,
241 ->function_node<input_t<decltype(decide_on_callable_type<Body>(0))>,
242  output_t<decltype(decide_on_callable_type<Body>(0))>,
243  queueing>;
244 
245 template <typename Output>
246 struct continue_output {
247  using type = Output;
248 };
249 
250 template <>
251 struct continue_output<void> {
252  using type = continue_msg;
253 };
254 
255 template <typename T>
256 using continue_output_t = typename continue_output<T>::type;
257 
258 template <typename GraphOrSet, typename Body, typename Policy>
259 continue_node(GraphOrSet&&, Body,
261 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
262  Policy>;
263 
264 template <typename GraphOrSet, typename Body, typename Policy>
265 continue_node(GraphOrSet&&,
266  int, Body,
268 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
269  Policy>;
270 
271 template <typename GraphOrSet, typename Body>
272 continue_node(GraphOrSet&&,
274 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
276 
277 template <typename GraphOrSet, typename Body>
278 continue_node(GraphOrSet&&, int,
280 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
282 
283 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
284 
285 template <typename NodeSet>
286 overwrite_node(const NodeSet&)
287 ->overwrite_node<decide_on_set_t<NodeSet>>;
288 
289 template <typename NodeSet>
290 write_once_node(const NodeSet&)
291 ->write_once_node<decide_on_set_t<NodeSet>>;
292 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
293 } // namespace interfaceX
294 } // namespace flow
295 } // namespace tbb
296 
297 #endif // __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
298 #endif // __TBB_flow_graph_nodes_deduction_H
unsigned int node_priority_t
#define __TBB_FLOW_GRAPH_PRIORITY_ARG1(arg1, priority)
static const node_priority_t no_priority
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
The graph class.

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.