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 template <typename GraphOrSet, typename Body>
84 source_node(GraphOrSet&&, Body, bool = true)
85 ->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
86 
87 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
88 
89 template <typename NodeSet>
90 struct decide_on_set;
91 
92 template <typename Node, typename... Nodes>
93 struct decide_on_set<node_set<internal::order::following, Node, Nodes...>> {
94  using type = typename Node::output_type;
95 };
96 
97 template <typename Node, typename... Nodes>
98 struct decide_on_set<node_set<internal::order::preceding, Node, Nodes...>> {
99  using type = typename Node::input_type;
100 };
101 
102 template <typename NodeSet>
103 using decide_on_set_t = typename decide_on_set<std::decay_t<NodeSet>>::type;
104 
105 template <typename NodeSet>
106 broadcast_node(const NodeSet&)
107 ->broadcast_node<decide_on_set_t<NodeSet>>;
108 
109 template <typename NodeSet>
110 buffer_node(const NodeSet&)
111 ->buffer_node<decide_on_set_t<NodeSet>>;
112 
113 template <typename NodeSet>
114 queue_node(const NodeSet&)
115 ->queue_node<decide_on_set_t<NodeSet>>;
116 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
117 
118 template <typename GraphOrProxy, typename Sequencer>
119 sequencer_node(GraphOrProxy&&, Sequencer)
120 ->sequencer_node<input_t<decltype(decide_on_callable_type<Sequencer>(0))>>;
121 
122 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
123 template <typename NodeSet, typename Compare>
124 priority_queue_node(const NodeSet&, const Compare&)
125 ->priority_queue_node<decide_on_set_t<NodeSet>, Compare>;
126 
127 template <typename NodeSet>
128 priority_queue_node(const NodeSet&)
129 ->priority_queue_node<decide_on_set_t<NodeSet>, std::less<decide_on_set_t<NodeSet>>>;
130 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
131 
132 template <typename Key>
133 struct join_key {
134  using type = Key;
135 };
136 
137 template <typename T>
138 struct join_key<const T&> {
139  using type = T&;
140 };
141 
142 template <typename Key>
143 using join_key_t = typename join_key<Key>::type;
144 
145 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
146 template <typename Policy, typename... Predecessors>
147 join_node(const node_set<internal::order::following, Predecessors...>&, Policy)
148 ->join_node<std::tuple<typename Predecessors::output_type...>,
149  Policy>;
150 
151 template <typename Policy, typename Successor, typename... Successors>
152 join_node(const node_set<internal::order::preceding, Successor, Successors...>&, Policy)
153 ->join_node<typename Successor::input_type, Policy>;
154 
155 template <typename... Predecessors>
156 join_node(const node_set<internal::order::following, Predecessors...>)
157 ->join_node<std::tuple<typename Predecessors::output_type...>,
158  queueing>;
159 
160 template <typename Successor, typename... Successors>
161 join_node(const node_set<internal::order::preceding, Successor, Successors...>)
162 ->join_node<typename Successor::input_type, queueing>;
163 #endif
164 
165 template <typename GraphOrProxy, typename Body, typename... Bodies>
166 join_node(GraphOrProxy&&, Body, Bodies...)
167 ->join_node<std::tuple<input_t<decltype(decide_on_callable_type<Body>(0))>,
168  input_t<decltype(decide_on_callable_type<Bodies>(0))>...>,
169  key_matching<join_key_t<output_t<decltype(decide_on_callable_type<Body>(0))>>>>;
170 
171 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
172 template <typename... Predecessors>
173 indexer_node(const node_set<internal::order::following, Predecessors...>&)
174 ->indexer_node<typename Predecessors::output_type...>;
175 #endif
176 
177 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
178 template <typename NodeSet>
179 limiter_node(const NodeSet&, size_t)
180 ->limiter_node<decide_on_set_t<NodeSet>>;
181 
182 template <typename Predecessor, typename... Predecessors>
183 split_node(const node_set<internal::order::following, Predecessor, Predecessors...>&)
184 ->split_node<typename Predecessor::output_type>;
185 
186 template <typename... Successors>
187 split_node(const node_set<internal::order::preceding, Successors...>&)
188 ->split_node<std::tuple<typename Successors::input_type...>>;
189 
190 #endif
191 
192 template <typename GraphOrSet, typename Body, typename Policy>
193 function_node(GraphOrSet&&,
194  size_t, Body,
196 ->function_node<input_t<decltype(decide_on_callable_type<Body>(0))>,
197  output_t<decltype(decide_on_callable_type<Body>(0))>,
198  Policy>;
199 
200 template <typename GraphOrSet, typename Body>
201 function_node(GraphOrSet&&, size_t,
203 ->function_node<input_t<decltype(decide_on_callable_type<Body>(0))>,
204  output_t<decltype(decide_on_callable_type<Body>(0))>,
205  queueing>;
206 
207 template <typename Output>
208 struct continue_output {
209  using type = Output;
210 };
211 
212 template <>
213 struct continue_output<void> {
214  using type = continue_msg;
215 };
216 
217 template <typename T>
218 using continue_output_t = typename continue_output<T>::type;
219 
220 template <typename GraphOrSet, typename Body, typename Policy>
221 continue_node(GraphOrSet&&, Body,
223 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
224  Policy>;
225 
226 template <typename GraphOrSet, typename Body, typename Policy>
227 continue_node(GraphOrSet&&,
228  int, Body,
230 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
231  Policy>;
232 
233 template <typename GraphOrSet, typename Body>
234 continue_node(GraphOrSet&&,
236 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
238 
239 template <typename GraphOrSet, typename Body>
240 continue_node(GraphOrSet&&, int,
242 ->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
244 
245 #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
246 
247 template <typename NodeSet>
248 overwrite_node(const NodeSet&)
249 ->overwrite_node<decide_on_set_t<NodeSet>>;
250 
251 template <typename NodeSet>
252 write_once_node(const NodeSet&)
253 ->write_once_node<decide_on_set_t<NodeSet>>;
254 #endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
255 } // namespace interfaceX
256 } // namespace flow
257 } // namespace tbb
258 
259 #endif // __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
260 #endif // __TBB_flow_graph_nodes_deduction_H
internal
Definition: _flow_graph_async_msg_impl.h:24
void
void
Definition: ittnotify_static.h:91
__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
internal::Policy
Definition: _flow_graph_body_impl.h:34
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.