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 template <typename T> struct body_types;
33 
34 template <typename T, typename Input, typename Output>
35 struct body_types<Output (T::*)(const Input&) const> : declare_body_types<Input, Output> {};
36 
37 template <typename T, typename Input, typename Output>
38 struct body_types<Output (T::*)(const Input&)> : declare_body_types<Input, Output> {};
39 
40 template <typename T, typename Input, typename Output>
41 struct body_types<Output (T::*)(Input&) const> : declare_body_types<Input, Output> {};
42 
43 template <typename T, typename Input, typename Output>
44 struct body_types<Output (T::*)(Input&)> : declare_body_types<Input, Output> {};
45 
46 template <typename Input, typename Output>
47 struct body_types<Output (*)(Input&)> : declare_body_types<Input, Output> {};
48 
49 template <typename Input, typename Output>
50 struct body_types<Output (*)(const Input&)> : declare_body_types<Input, Output> {};
51 
52 template <typename Body>
53 using input_t = typename body_types<Body>::input_type;
54 
55 template <typename Body>
56 using output_t = typename body_types<Body>::output_type;
57 
58 template <typename T, typename Input, typename Output>
59 auto decide_on_operator_overload(Output (T::*name)(const Input&) const)->decltype(name);
60 
61 template <typename T, typename Input, typename Output>
62 auto decide_on_operator_overload(Output (T::*name)(const Input&))->decltype(name);
63 
64 template <typename T, typename Input, typename Output>
65 auto decide_on_operator_overload(Output (T::*name)(Input&) const)->decltype(name);
66 
67 template <typename T, typename Input, typename Output>
68 auto decide_on_operator_overload(Output (T::*name)(Input&))->decltype(name);
69 
70 template <typename Input, typename Output>
71 auto decide_on_operator_overload(Output (*name)(const Input&))->decltype(name);
72 
73 template <typename Input, typename Output>
74 auto decide_on_operator_overload(Output (*name)(Input&))->decltype(name);
75 
76 template <typename Body>
77 decltype(decide_on_operator_overload(&Body::operator())) decide_on_callable_type(int);
78 
79 template <typename Body>
80 decltype(decide_on_operator_overload(std::declval<Body>())) decide_on_callable_type(...);
81 
82 // Deduction guides for Flow Graph nodes
83 #if TBB_USE_SOURCE_NODE_AS_ALIAS
84 template <typename GraphOrSet, typename Body>
85 source_node(GraphOrSet&&, Body)
86 ->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
87 #else
88 template <typename GraphOrSet, typename Body>
89 source_node(GraphOrSet&&, Body, bool = true)
90 ->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
91 #endif
92 
93 template <typename GraphOrSet, typename Body>
94 input_node(GraphOrSet&&, Body, bool = true)
95 ->input_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
96 
97 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
98 
99 template <typename NodeSet>
100 struct decide_on_set;
101 
102 template <typename Node, typename... Nodes>
103 struct decide_on_set<node_set<internal::order::following, Node, Nodes...>> {
104  using type = typename Node::output_type;
105 };
106 
107 template <typename Node, typename... Nodes>
108 struct decide_on_set<node_set<internal::order::preceding, Node, Nodes...>> {
109  using type = typename Node::input_type;
110 };
111 
112 template <typename NodeSet>
113 using decide_on_set_t = typename decide_on_set<std::decay_t<NodeSet>>::type;
114 
115 template <typename NodeSet>
116 broadcast_node(const NodeSet&)
117 ->broadcast_node<decide_on_set_t<NodeSet>>;
118 
119 template <typename NodeSet>
120 buffer_node(const NodeSet&)
121 ->buffer_node<decide_on_set_t<NodeSet>>;
122 
123 template <typename NodeSet>
124 queue_node(const NodeSet&)
125 ->queue_node<decide_on_set_t<NodeSet>>;
126 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
127 
128 template <typename GraphOrProxy, typename Sequencer>
129 sequencer_node(GraphOrProxy&&, Sequencer)
130 ->sequencer_node<input_t<decltype(decide_on_callable_type<Sequencer>(0))>>;
131 
132 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
133 template <typename NodeSet, typename Compare>
134 priority_queue_node(const NodeSet&, const Compare&)
135 ->priority_queue_node<decide_on_set_t<NodeSet>, Compare>;
136 
137 template <typename NodeSet>
138 priority_queue_node(const NodeSet&)
139 ->priority_queue_node<decide_on_set_t<NodeSet>, std::less<decide_on_set_t<NodeSet>>>;
140 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
141 
142 template <typename Key>
143 struct join_key {
144  using type = Key;
145 };
146 
147 template <typename T>
148 struct join_key<const T&> {
149  using type = T&;
150 };
151 
152 template <typename Key>
153 using join_key_t = typename join_key<Key>::type;
154 
155 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
156 template <typename Policy, typename... Predecessors>
157 join_node(const node_set<internal::order::following, Predecessors...>&, Policy)
158 ->join_node<std::tuple<typename Predecessors::output_type...>,
159  Policy>;
160 
161 template <typename Policy, typename Successor, typename... Successors>
162 join_node(const node_set<internal::order::preceding, Successor, Successors...>&, Policy)
163 ->join_node<typename Successor::input_type, Policy>;
164 
165 template <typename... Predecessors>
166 join_node(const node_set<internal::order::following, Predecessors...>)
167 ->join_node<std::tuple<typename Predecessors::output_type...>,
168  queueing>;
169 
170 template <typename Successor, typename... Successors>
171 join_node(const node_set<internal::order::preceding, Successor, Successors...>)
172 ->join_node<typename Successor::input_type, queueing>;
173 #endif
174 
175 template <typename GraphOrProxy, typename Body, typename... Bodies>
176 join_node(GraphOrProxy&&, Body, Bodies...)
177 ->join_node<std::tuple<input_t<decltype(decide_on_callable_type<Body>(0))>,
178  input_t<decltype(decide_on_callable_type<Bodies>(0))>...>,
179  key_matching<join_key_t<output_t<decltype(decide_on_callable_type<Body>(0))>>>>;
180 
181 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
182 template <typename... Predecessors>
183 indexer_node(const node_set<internal::order::following, Predecessors...>&)
184 ->indexer_node<typename Predecessors::output_type...>;
185 #endif
186 
187 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
188 template <typename NodeSet>
189 limiter_node(const NodeSet&, size_t)
190 ->limiter_node<decide_on_set_t<NodeSet>>;
191 
192 template <typename Predecessor, typename... Predecessors>
193 split_node(const node_set<internal::order::following, Predecessor, Predecessors...>&)
194 ->split_node<typename Predecessor::output_type>;
195 
196 template <typename... Successors>
197 split_node(const node_set<internal::order::preceding, Successors...>&)
198 ->split_node<std::tuple<typename Successors::input_type...>>;
199 
200 #endif
201 
202 template <typename GraphOrSet, typename Body, typename Policy>
203 function_node(GraphOrSet&&,
204  size_t, Body,
206 ->function_node<input_t<decltype(decide_on_callable_type<Body>(0))>,
207  output_t<decltype(decide_on_callable_type<Body>(0))>,
208  Policy>;
209 
210 template <typename GraphOrSet, typename Body>
211 function_node(GraphOrSet&&, size_t,
213 ->function_node<input_t<decltype(decide_on_callable_type<Body>(0))>,
214  output_t<decltype(decide_on_callable_type<Body>(0))>,
215  queueing>;
216 
217 template <typename Output>
218 struct continue_output {
219  using type = Output;
220 };
221 
222 template <>
223 struct continue_output<void> {
224  using type = continue_msg;
225 };
226 
227 template <typename T>
228 using continue_output_t = typename continue_output<T>::type;
229 
230 template <typename GraphOrSet, typename Body, typename Policy>
231 continue_node(GraphOrSet&&, Body,
233 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
234  Policy>;
235 
236 template <typename GraphOrSet, typename Body, typename Policy>
237 continue_node(GraphOrSet&&,
238  int, Body,
240 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
241  Policy>;
242 
243 template <typename GraphOrSet, typename Body>
244 continue_node(GraphOrSet&&,
246 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
248 
249 template <typename GraphOrSet, typename Body>
250 continue_node(GraphOrSet&&, int,
252 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
254 
255 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
256 
257 template <typename NodeSet>
258 overwrite_node(const NodeSet&)
259 ->overwrite_node<decide_on_set_t<NodeSet>>;
260 
261 template <typename NodeSet>
262 write_once_node(const NodeSet&)
263 ->write_once_node<decide_on_set_t<NodeSet>>;
264 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
265 } // namespace interfaceX
266 } // namespace flow
267 } // namespace tbb
268 
269 #endif // __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
270 #endif // __TBB_flow_graph_nodes_deduction_H
internal
Definition: _flow_graph_async_msg_impl.h:24
void
void
Definition: ittnotify_static.h:91
internal::Policy
Definition: _flow_graph_body_impl.h:34
__TBB_FLOW_GRAPH_PRIORITY_ARG1
#define __TBB_FLOW_GRAPH_PRIORITY_ARG1(arg1, priority)
Definition: _flow_graph_impl.h:40
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::flow::internal::no_priority
static const node_priority_t no_priority
Definition: _flow_graph_impl.h:64
tbb::flow::internal::node_priority_t
unsigned int node_priority_t
Definition: _flow_graph_impl.h:63
name
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
Definition: ittnotify_static.h:93
type
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
Definition: ittnotify_static.h:198

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.