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
22namespace tbb {
23namespace flow {
24namespace interface11 {
25
26template <typename Input, typename Output>
27struct declare_body_types {
28 using input_type = Input;
29 using output_type = Output;
30};
31
32template <typename T> struct body_types;
33
34template <typename T, typename Input, typename Output>
35struct body_types<Output (T::*)(const Input&) const> : declare_body_types<Input, Output> {};
36
37template <typename T, typename Input, typename Output>
38struct body_types<Output (T::*)(const Input&)> : declare_body_types<Input, Output> {};
39
40template <typename T, typename Input, typename Output>
41struct body_types<Output (T::*)(Input&) const> : declare_body_types<Input, Output> {};
42
43template <typename T, typename Input, typename Output>
44struct body_types<Output (T::*)(Input&)> : declare_body_types<Input, Output> {};
45
46template <typename Input, typename Output>
47struct body_types<Output (*)(Input&)> : declare_body_types<Input, Output> {};
48
49template <typename Input, typename Output>
50struct body_types<Output (*)(const Input&)> : declare_body_types<Input, Output> {};
51
52template <typename Body>
53using input_t = typename body_types<Body>::input_type;
54
55template <typename Body>
56using output_t = typename body_types<Body>::output_type;
57
58template <typename T, typename Input, typename Output>
59auto decide_on_operator_overload(Output (T::*name)(const Input&) const)->decltype(name);
60
61template <typename T, typename Input, typename Output>
62auto decide_on_operator_overload(Output (T::*name)(const Input&))->decltype(name);
63
64template <typename T, typename Input, typename Output>
65auto decide_on_operator_overload(Output (T::*name)(Input&) const)->decltype(name);
66
67template <typename T, typename Input, typename Output>
68auto decide_on_operator_overload(Output (T::*name)(Input&))->decltype(name);
69
70template <typename Input, typename Output>
71auto decide_on_operator_overload(Output (*name)(const Input&))->decltype(name);
72
73template <typename Input, typename Output>
74auto decide_on_operator_overload(Output (*name)(Input&))->decltype(name);
75
76template <typename Body>
77decltype(decide_on_operator_overload(&Body::operator())) decide_on_callable_type(int);
78
79template <typename Body>
80decltype(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
84template <typename GraphOrSet, typename Body>
85source_node(GraphOrSet&&, Body)
86->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
87#else
88template <typename GraphOrSet, typename Body>
89source_node(GraphOrSet&&, Body, bool = true)
90->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
91#endif
92
93template <typename GraphOrSet, typename Body>
94input_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
99template <typename NodeSet>
100struct decide_on_set;
101
102template <typename Node, typename... Nodes>
103struct decide_on_set<node_set<internal::order::following, Node, Nodes...>> {
104 using type = typename Node::output_type;
105};
106
107template <typename Node, typename... Nodes>
108struct decide_on_set<node_set<internal::order::preceding, Node, Nodes...>> {
109 using type = typename Node::input_type;
110};
111
112template <typename NodeSet>
113using decide_on_set_t = typename decide_on_set<std::decay_t<NodeSet>>::type;
114
115template <typename NodeSet>
116broadcast_node(const NodeSet&)
117->broadcast_node<decide_on_set_t<NodeSet>>;
118
119template <typename NodeSet>
120buffer_node(const NodeSet&)
121->buffer_node<decide_on_set_t<NodeSet>>;
122
123template <typename NodeSet>
124queue_node(const NodeSet&)
125->queue_node<decide_on_set_t<NodeSet>>;
126#endif // __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
127
128template <typename GraphOrProxy, typename Sequencer>
129sequencer_node(GraphOrProxy&&, Sequencer)
130->sequencer_node<input_t<decltype(decide_on_callable_type<Sequencer>(0))>>;
131
132#if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
133template <typename NodeSet, typename Compare>
134priority_queue_node(const NodeSet&, const Compare&)
135->priority_queue_node<decide_on_set_t<NodeSet>, Compare>;
136
137template <typename NodeSet>
138priority_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
142template <typename Key>
143struct join_key {
144 using type = Key;
145};
146
147template <typename T>
148struct join_key<const T&> {
149 using type = T&;
150};
151
152template <typename Key>
153using join_key_t = typename join_key<Key>::type;
154
155#if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
156template <typename Policy, typename... Predecessors>
157join_node(const node_set<internal::order::following, Predecessors...>&, Policy)
158->join_node<std::tuple<typename Predecessors::output_type...>,
159 Policy>;
160
161template <typename Policy, typename Successor, typename... Successors>
162join_node(const node_set<internal::order::preceding, Successor, Successors...>&, Policy)
163->join_node<typename Successor::input_type, Policy>;
164
165template <typename... Predecessors>
166join_node(const node_set<internal::order::following, Predecessors...>)
167->join_node<std::tuple<typename Predecessors::output_type...>,
168 queueing>;
169
170template <typename Successor, typename... Successors>
171join_node(const node_set<internal::order::preceding, Successor, Successors...>)
172->join_node<typename Successor::input_type, queueing>;
173#endif
174
175template <typename GraphOrProxy, typename Body, typename... Bodies>
176join_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
182template <typename... Predecessors>
183indexer_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
188template <typename NodeSet>
189limiter_node(const NodeSet&, size_t)
190->limiter_node<decide_on_set_t<NodeSet>>;
191
192template <typename Predecessor, typename... Predecessors>
193split_node(const node_set<internal::order::following, Predecessor, Predecessors...>&)
194->split_node<typename Predecessor::output_type>;
195
196template <typename... Successors>
197split_node(const node_set<internal::order::preceding, Successors...>&)
198->split_node<std::tuple<typename Successors::input_type...>>;
199
200#endif
201
202template <typename GraphOrSet, typename Body, typename Policy>
203function_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
210template <typename GraphOrSet, typename Body>
211function_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
217template <typename Output>
218struct continue_output {
219 using type = Output;
220};
221
222template <>
223struct continue_output<void> {
224 using type = continue_msg;
225};
226
227template <typename T>
228using continue_output_t = typename continue_output<T>::type;
229
230template <typename GraphOrSet, typename Body, typename Policy>
231continue_node(GraphOrSet&&, Body,
233->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
234 Policy>;
235
236template <typename GraphOrSet, typename Body, typename Policy>
237continue_node(GraphOrSet&&,
238 int, Body,
240->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
241 Policy>;
242
243template <typename GraphOrSet, typename Body>
244continue_node(GraphOrSet&&,
246->continue_node<continue_output_t<std::invoke_result_t<Body, continue_msg>>,
248
249template <typename GraphOrSet, typename Body>
250continue_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
257template <typename NodeSet>
258overwrite_node(const NodeSet&)
259->overwrite_node<decide_on_set_t<NodeSet>>;
260
261template <typename NodeSet>
262write_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
#define __TBB_FLOW_GRAPH_PRIORITY_ARG1(arg1, 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.
static const node_priority_t no_priority
unsigned int node_priority_t

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.