proxygen
CompileTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
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  */
25 
26 using namespace folly::pushmi::aliases;
27 
30 
31 using namespace testing;
32 
33 using namespace std::literals;
34 
35 #if __cpp_deduction_guides >= 201703
36 #define MAKE(x) x MAKE_
37 #define MAKE_(...) \
38  { __VA_ARGS__ }
39 #else
40 #define MAKE(x) make_##x
41 #endif
42 
44  auto out0 = mi::MAKE(receiver)();
45  static_assert(mi::Receiver<decltype(out0)>, "out0 not a receiver");
46  auto out1 = mi::MAKE(receiver)(mi::ignoreVF{});
47  static_assert(mi::Receiver<decltype(out1)>, "out1 not a receiver");
48  auto out2 = mi::MAKE(receiver)(mi::ignoreVF{}, mi::abortEF{});
49  static_assert(mi::Receiver<decltype(out2)>, "out2 not a receiver");
50  auto out3 = mi::MAKE(receiver)(mi::ignoreVF{}, mi::abortEF{}, mi::ignoreDF{});
51  static_assert(mi::Receiver<decltype(out3)>, "out3 not a receiver");
52  auto out4 = mi::MAKE(receiver)([](auto e) noexcept { e.get(); });
53  static_assert(mi::Receiver<decltype(out4)>, "out4 not a receiver");
54  auto out5 = mi::MAKE(receiver)(mi::on_value([]() {}));
55  static_assert(mi::Receiver<decltype(out5)>, "out5 not a receiver");
56  auto out6 = mi::MAKE(receiver)(mi::on_error(
57  [](std::exception_ptr) noexcept {}, [](auto e) noexcept { e.get(); }));
58  static_assert(mi::Receiver<decltype(out6)>, "out6 not a receiver");
59  auto out7 = mi::MAKE(receiver)(mi::on_done([]() {}));
60  static_assert(mi::Receiver<decltype(out7)>, "out7 not a receiver");
61 
62  using Out0 = decltype(out0);
63 
64  auto proxy0 = mi::MAKE(receiver)(out0);
65  static_assert(mi::Receiver<decltype(proxy0)>, "proxy0 not a receiver");
66  auto proxy1 = mi::MAKE(receiver)(out0, mi::passDVF{});
67  static_assert(mi::Receiver<decltype(proxy1)>, "proxy1 not a receiver");
68  auto proxy2 =
69  mi::MAKE(receiver)(out0, mi::passDVF{}, mi::on_error(mi::passDEF{}));
70  static_assert(mi::Receiver<decltype(proxy2)>, "proxy2 not a receiver");
71  auto proxy3 =
72  mi::MAKE(receiver)(out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
73  static_assert(mi::Receiver<decltype(proxy3)>, "proxy3 not a receiver");
74  auto proxy4 =
75  mi::MAKE(receiver)(out0, [](Out0&) {}, mi::on_error([
76  ](Out0 & d, auto e) noexcept { d.error(e); }));
77  static_assert(mi::Receiver<decltype(proxy4)>, "proxy4 not a receiver");
78  auto proxy5 = mi::MAKE(receiver)(out0, mi::on_value([](Out0&) {}));
79  static_assert(mi::Receiver<decltype(proxy5)>, "proxy5 not a receiver");
80  auto proxy6 = mi::MAKE(receiver)(
81  out0, mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
82  ](Out0&, auto e) noexcept { e.get(); }));
83  static_assert(mi::Receiver<decltype(proxy6)>, "proxy6 not a receiver");
84  auto proxy7 = mi::MAKE(receiver)(out0, mi::on_done([](Out0&) {}));
85  static_assert(mi::Receiver<decltype(proxy7)>, "proxy7 not a receiver");
86 
87  std::promise<void> p0;
88  auto promise0 = mi::MAKE(receiver)(std::move(p0));
89  promise0.done();
90 
91  std::promise<void> p1;
92 
93  auto any0 = mi::any_receiver<>(std::move(p1));
94  auto any1 = mi::any_receiver<>(std::move(promise0));
95  auto any2 = mi::any_receiver<>(out0);
96  auto any3 = mi::any_receiver<>(proxy0);
97 }
98 
100  auto out0 = mi::MAKE(receiver)();
101  static_assert(mi::Receiver<decltype(out0)>, "out0 not a receiver");
102  auto out1 = mi::MAKE(receiver)(mi::ignoreVF{});
103  static_assert(mi::Receiver<decltype(out1)>, "out1 not a receiver");
104  auto out2 = mi::MAKE(receiver)(mi::ignoreVF{}, mi::abortEF{});
105  static_assert(mi::Receiver<decltype(out2)>, "out2 not a receiver");
106  auto out3 = mi::MAKE(receiver)(mi::ignoreVF{}, mi::abortEF{}, mi::ignoreDF{});
107  static_assert(mi::Receiver<decltype(out3)>, "out3 not a receiver");
108  auto out4 = mi::MAKE(receiver)([](auto v) { v.get(); });
109  static_assert(mi::Receiver<decltype(out4)>, "out4 not a receiver");
110  auto out5 = mi::MAKE(receiver)(
111  mi::on_value([](auto v) { v.get(); }, [](int) {}),
112  mi::on_error([](std::exception_ptr) noexcept {}, [](auto e) noexcept {
113  e.get();
114  }));
115  static_assert(mi::Receiver<decltype(out5)>, "out5 not a receiver");
116  auto out6 = mi::MAKE(receiver)(mi::on_error(
117  [](std::exception_ptr) noexcept {}, [](auto e) noexcept { e.get(); }));
118  static_assert(mi::Receiver<decltype(out6)>, "out6 not a receiver");
119  auto out7 = mi::MAKE(receiver)(mi::on_done([]() {}));
120  static_assert(mi::Receiver<decltype(out7)>, "out7 not a receiver");
121 
122  using Out0 = decltype(out0);
123 
124  auto proxy0 = mi::MAKE(receiver)(out0);
125  static_assert(mi::Receiver<decltype(proxy0)>, "proxy0 not a receiver");
126  auto proxy1 = mi::MAKE(receiver)(out0, mi::passDVF{});
127  static_assert(mi::Receiver<decltype(proxy1)>, "proxy1 not a receiver");
128  auto proxy2 =
129  mi::MAKE(receiver)(out0, mi::passDVF{}, mi::on_error(mi::passDEF{}));
130  static_assert(mi::Receiver<decltype(proxy2)>, "proxy2 not a receiver");
131  auto proxy3 =
132  mi::MAKE(receiver)(out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
133  static_assert(mi::Receiver<decltype(proxy3)>, "proxy3 not a receiver");
134  auto proxy4 = mi::MAKE(receiver)(
135  out0, [](auto d, auto v) { mi::set_value(d, v.get()); });
136  static_assert(mi::Receiver<decltype(proxy4)>, "proxy4 not a receiver");
137  auto proxy5 = mi::MAKE(receiver)(
138  out0,
139  mi::on_value([](Out0&, auto v) { v.get(); }, [](Out0&, int) {}),
140  mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
141  ](Out0&, auto e) noexcept { e.get(); }));
142  static_assert(mi::Receiver<decltype(proxy5)>, "proxy5 not a receiver");
143  auto proxy6 = mi::MAKE(receiver)(
144  out0, mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
145  ](Out0&, auto e) noexcept { e.get(); }));
146  static_assert(mi::Receiver<decltype(proxy6)>, "proxy6 not a receiver");
147  auto proxy7 = mi::MAKE(receiver)(out0, mi::on_done([](Out0&) {}));
148  static_assert(mi::Receiver<decltype(proxy7)>, "proxy7 not a receiver");
149 
150  std::promise<int> p0;
151  auto promise0 = mi::MAKE(receiver)(std::move(p0));
152  promise0.value(0);
153 
154  std::promise<int> p1;
155 
159  auto any3 = mi::any_receiver<std::exception_ptr, int>(proxy0);
160 }
161 
163  auto out0 = mi::MAKE(receiver)();
164  static_assert(mi::Receiver<decltype(out0)>, "out0 not a receiver");
165  auto out1 = mi::MAKE(receiver)(mi::ignoreNF{});
166  static_assert(mi::Receiver<decltype(out1)>, "out1 not a receiver");
167  auto out2 = mi::MAKE(receiver)(mi::ignoreNF{}, mi::abortEF{});
168  static_assert(mi::Receiver<decltype(out2)>, "out2 not a receiver");
169  auto out3 = mi::MAKE(receiver)(mi::ignoreNF{}, mi::abortEF{}, mi::ignoreDF{});
170  static_assert(mi::Receiver<decltype(out3)>, "out3 not a receiver");
171  auto out4 = mi::MAKE(receiver)([](auto v) { v.get(); });
172  static_assert(mi::Receiver<decltype(out4)>, "out4 not a receiver");
173  auto out5 = mi::MAKE(receiver)(
174  mi::on_value([](auto v) { v.get(); }, [](int) {}),
175  mi::on_error([](std::exception_ptr) noexcept {}, [](auto e) noexcept {
176  e.get();
177  }));
178  static_assert(mi::Receiver<decltype(out5)>, "out5 not a receiver");
179  auto out6 = mi::MAKE(receiver)(mi::on_error(
180  [](std::exception_ptr) noexcept {}, [](auto e) noexcept { e.get(); }));
181  static_assert(mi::Receiver<decltype(out6)>, "out6 not a receiver");
182  auto out7 = mi::MAKE(receiver)(mi::on_done([]() {}));
183  static_assert(mi::Receiver<decltype(out7)>, "out7 not a receiver");
184 
185  using Out0 = decltype(out0);
186 
187  auto proxy0 = mi::MAKE(receiver)(out0);
188  static_assert(mi::Receiver<decltype(proxy0)>, "proxy0 not a receiver");
189  auto proxy1 = mi::MAKE(receiver)(out0, mi::passDVF{});
190  static_assert(mi::Receiver<decltype(proxy1)>, "proxy1 not a receiver");
191  auto proxy2 =
192  mi::MAKE(receiver)(out0, mi::passDVF{}, mi::on_error(mi::passDEF{}));
193  static_assert(mi::Receiver<decltype(proxy2)>, "proxy2 not a receiver");
194  auto proxy3 =
195  mi::MAKE(receiver)(out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
196  static_assert(mi::Receiver<decltype(proxy3)>, "proxy3 not a receiver");
197  auto proxy4 = mi::MAKE(receiver)(
198  out0, [](auto d, auto v) { mi::set_value(d, v.get()); });
199  static_assert(mi::Receiver<decltype(proxy4)>, "proxy4 not a receiver");
200  auto proxy5 = mi::MAKE(receiver)(
201  out0,
202  mi::on_value([](Out0&, auto v) { v.get(); }, [](Out0&, int) {}),
203  mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
204  ](Out0&, auto e) noexcept { e.get(); }));
205  static_assert(mi::Receiver<decltype(proxy5)>, "proxy5 not a receiver");
206  auto proxy6 = mi::MAKE(receiver)(
207  out0, mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
208  ](Out0&, auto e) noexcept { e.get(); }));
209  static_assert(mi::Receiver<decltype(proxy6)>, "proxy6 not a receiver");
210  auto proxy7 = mi::MAKE(receiver)(out0, mi::on_done([](Out0&) {}));
211  static_assert(mi::Receiver<decltype(proxy7)>, "proxy7 not a receiver");
212 
214  auto any1 = mi::any_receiver<std::exception_ptr, int>(proxy0);
215 }
216 
218  auto in0 = mi::MAKE(single_sender)();
219  static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
220  auto in1 = mi::MAKE(single_sender)(mi::ignoreSF{});
221  static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
222  auto in2 = mi::MAKE(single_sender)(mi::ignoreSF{}, mi::trampolineEXF{});
223  static_assert(mi::Sender<decltype(in2)>, "in2 not a sender");
224  auto in3 = mi::MAKE(single_sender)(
225  [&](auto out) {
226  in0.submit(mi::MAKE(receiver)(
227  std::move(out),
228  mi::on_value([](auto d, int v) { mi::set_value(d, v); })));
229  },
230  []() { return mi::trampoline(); });
231  static_assert(mi::Sender<decltype(in3)>, "in3 not a sender");
232 
233  std::promise<int> p0;
234  auto promise0 = mi::MAKE(receiver)(std::move(p0));
235  in0 | ep::submit(std::move(promise0));
236 
237  auto out0 = mi::MAKE(receiver)();
238  auto out1 = mi::MAKE(receiver)(
239  out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
240  in3.submit(out1);
241 
243 
244  static_assert(
245  mi::Executor<mi::executor_t<decltype(in0)>>,
246  "sender has invalid executor");
247 }
248 
250  auto in0 = mi::MAKE(many_sender)();
251  static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
252  auto in1 = mi::MAKE(many_sender)(mi::ignoreSF{});
253  static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
254  auto in2 = mi::MAKE(many_sender)(mi::ignoreSF{}, mi::trampolineEXF{});
255  static_assert(mi::Sender<decltype(in2)>, "in2 not a sender");
256  auto in3 = mi::MAKE(many_sender)(
257  [&](auto out) {
258  in0.submit(mi::MAKE(receiver)(
259  std::move(out),
260  mi::on_value([](auto d, int v) { mi::set_value(d, v); })));
261  },
262  []() { return mi::trampoline(); });
263  static_assert(mi::Sender<decltype(in3)>, "in3 not a sender");
264 
265  auto out0 = mi::MAKE(receiver)();
266  auto out1 = mi::MAKE(receiver)(
267  out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
268  in3.submit(out1);
269 
271 
272  static_assert(
273  mi::Executor<mi::executor_t<decltype(in0)>>,
274  "sender has invalid executor");
275 }
276 
278  auto in0 = mi::MAKE(constrained_single_sender)();
279  static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
280  auto in1 = mi::MAKE(constrained_single_sender)(mi::ignoreSF{});
281  static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
282  auto in2 = mi::MAKE(constrained_single_sender)(
284  static_assert(mi::Sender<decltype(in2)>, "in2 not a sender");
285  auto in3 = mi::MAKE(constrained_single_sender)(
286  [&](auto c, auto out) {
287  in0.submit(
288  c,
289  mi::MAKE(receiver)(std::move(out), mi::on_value([](auto d, int v) {
290  mi::set_value(d, v);
291  })));
292  },
293  []() { return mi::inline_constrained_executor(); },
294  []() { return 0; });
295  static_assert(mi::Sender<decltype(in3)>, "in3 not a sender");
296  auto in4 = mi::MAKE(constrained_single_sender)(
298  static_assert(mi::Sender<decltype(in4)>, "in4 not a sender");
299 
300  std::promise<int> p0;
301  auto promise0 = mi::MAKE(receiver)(std::move(p0));
302  in0.submit(in0.top(), std::move(promise0));
303 
304  auto out0 = mi::MAKE(receiver)();
305  auto out1 = mi::MAKE(receiver)(
306  out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
307  in3.submit(in0.top(), out1);
308 
309  auto any0 = mi::
311  in0);
312 
313  static_assert(
314  mi::Executor<mi::executor_t<decltype(in0)>>,
315  "sender has invalid executor");
316 
317  in3 | op::submit();
318  in3 | op::blocking_submit();
319 }
320 
322  auto in0 = mi::MAKE(time_single_sender)();
323  static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
324  auto in1 = mi::MAKE(time_single_sender)(mi::ignoreSF{});
325  static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
326  auto in2 = mi::MAKE(time_single_sender)(
328  static_assert(mi::Sender<decltype(in2)>, "in2 not a sender");
329  auto in3 = mi::MAKE(time_single_sender)(
330  [&](auto tp, auto out) {
331  in0.submit(
332  tp,
333  mi::MAKE(receiver)(std::move(out), mi::on_value([](auto d, int v) {
334  mi::set_value(d, v);
335  })));
336  },
337  []() { return mi::inline_time_executor(); },
338  []() { return std::chrono::system_clock::now(); });
339  static_assert(mi::Sender<decltype(in3)>, "in3 not a sender");
340  auto in4 = mi::MAKE(time_single_sender)(mi::ignoreSF{}, mi::inlineTimeEXF{});
341  static_assert(mi::Sender<decltype(in4)>, "in4 not a sender");
342 
343  std::promise<int> p0;
344  auto promise0 = mi::MAKE(receiver)(std::move(p0));
345  in0.submit(in0.top(), std::move(promise0));
346 
347  auto out0 = mi::MAKE(receiver)();
348  auto out1 = mi::MAKE(receiver)(
349  out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
350  in3.submit(in0.top(), out1);
351 
352  auto any0 = mi::any_time_single_sender<
353  std::exception_ptr,
354  std::chrono::system_clock::time_point,
355  int>(in0);
356 
357  static_assert(
358  mi::Executor<mi::executor_t<decltype(in0)>>,
359  "sender has invalid executor");
360 
361  in3 | op::submit();
362  in3 | op::blocking_submit();
363  in3 | op::submit_at(in3.top() + 1s);
364  in3 | op::submit_after(1s);
365 }
366 
368  auto out0 = mi::MAKE(flow_receiver)();
369  static_assert(mi::Receiver<decltype(out0)>, "out0 not a receiver");
370  auto out1 = mi::MAKE(flow_receiver)(mi::ignoreVF{});
371  static_assert(mi::Receiver<decltype(out1)>, "out1 not a receiver");
372  auto out2 = mi::MAKE(flow_receiver)(mi::ignoreVF{}, mi::abortEF{});
373  static_assert(mi::Receiver<decltype(out2)>, "out2 not a receiver");
374  auto out3 =
375  mi::MAKE(flow_receiver)(mi::ignoreVF{}, mi::abortEF{}, mi::ignoreDF{});
376  static_assert(mi::Receiver<decltype(out3)>, "out3 not a receiver");
377  auto out4 = mi::MAKE(flow_receiver)([](auto v) { v.get(); });
378  static_assert(mi::Receiver<decltype(out4)>, "out4 not a receiver");
379  auto out5 = mi::MAKE(flow_receiver)(
380  mi::on_value([](auto v) { v.get(); }, [](int) {}),
381  mi::on_error([](std::exception_ptr) noexcept {}, [](auto e) noexcept {
382  e.get();
383  }));
384  static_assert(mi::Receiver<decltype(out5)>, "out5 not a receiver");
385  auto out6 = mi::MAKE(flow_receiver)(mi::on_error(
386  [](std::exception_ptr) noexcept {}, [](auto e) noexcept { e.get(); }));
387  static_assert(mi::Receiver<decltype(out6)>, "out6 not a receiver");
388  auto out7 = mi::MAKE(flow_receiver)(mi::on_done([]() {}));
389  static_assert(mi::Receiver<decltype(out7)>, "out7 not a receiver");
390 
391  auto out8 = mi::MAKE(flow_receiver)(
393  static_assert(mi::Receiver<decltype(out8)>, "out8 not a receiver");
394 
395  using Out0 = decltype(out0);
396 
397  auto proxy0 = mi::MAKE(flow_receiver)(out0);
398  static_assert(mi::Receiver<decltype(proxy0)>, "proxy0 not a receiver");
399  auto proxy1 = mi::MAKE(flow_receiver)(out0, mi::passDVF{});
400  static_assert(mi::Receiver<decltype(proxy1)>, "proxy1 not a receiver");
401  auto proxy2 = mi::MAKE(flow_receiver)(out0, mi::passDVF{}, mi::passDEF{});
402  static_assert(mi::Receiver<decltype(proxy2)>, "proxy2 not a receiver");
403  auto proxy3 = mi::MAKE(flow_receiver)(
404  out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
405  static_assert(mi::Receiver<decltype(proxy3)>, "proxy3 not a receiver");
406  auto proxy4 = mi::MAKE(flow_receiver)(
407  out0, [](auto d, auto v) { mi::set_value(d, v.get()); });
408  static_assert(mi::Receiver<decltype(proxy4)>, "proxy4 not a receiver");
409  auto proxy5 = mi::MAKE(flow_receiver)(
410  out0,
411  mi::on_value([](Out0&, auto v) { v.get(); }, [](Out0&, int) {}),
412  mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
413  ](Out0&, auto e) noexcept { e.get(); }));
414  static_assert(mi::Receiver<decltype(proxy5)>, "proxy5 not a receiver");
415  auto proxy6 = mi::MAKE(flow_receiver)(
416  out0, mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
417  ](Out0&, auto e) noexcept { e.get(); }));
418  static_assert(mi::Receiver<decltype(proxy6)>, "proxy6 not a receiver");
419  auto proxy7 = mi::MAKE(flow_receiver)(out0, mi::on_done([](Out0&) {}));
420  static_assert(mi::Receiver<decltype(proxy7)>, "proxy7 not a receiver");
421 
422  auto proxy8 = mi::MAKE(flow_receiver)(
423  out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
424  static_assert(mi::Receiver<decltype(proxy8)>, "proxy8 not a receiver");
425 
426  auto any2 = mi::any_flow_receiver<
427  std::exception_ptr,
428  std::ptrdiff_t,
429  std::exception_ptr,
430  int>(out0);
431  auto any3 = mi::any_flow_receiver<
432  std::exception_ptr,
433  std::ptrdiff_t,
434  std::exception_ptr,
435  int>(proxy0);
436 }
437 
439  auto out0 = mi::MAKE(flow_receiver)();
440  static_assert(mi::Receiver<decltype(out0)>, "out0 not a receiver");
441  auto out1 = mi::MAKE(flow_receiver)(mi::ignoreVF{});
442  static_assert(mi::Receiver<decltype(out1)>, "out1 not a receiver");
443  auto out2 = mi::MAKE(flow_receiver)(mi::ignoreVF{}, mi::abortEF{});
444  static_assert(mi::Receiver<decltype(out2)>, "out2 not a receiver");
445  auto out3 =
446  mi::MAKE(flow_receiver)(mi::ignoreVF{}, mi::abortEF{}, mi::ignoreDF{});
447  static_assert(mi::Receiver<decltype(out3)>, "out3 not a receiver");
448  auto out4 = mi::MAKE(flow_receiver)([](auto v) { v.get(); });
449  static_assert(mi::Receiver<decltype(out4)>, "out4 not a receiver");
450  auto out5 = mi::MAKE(flow_receiver)(
451  mi::on_value([](auto v) { v.get(); }, [](int) {}),
452  mi::on_error([](std::exception_ptr) noexcept {}, [](auto e) noexcept {
453  e.get();
454  }));
455  static_assert(mi::Receiver<decltype(out5)>, "out5 not a receiver");
456  auto out6 = mi::MAKE(flow_receiver)(mi::on_error(
457  [](std::exception_ptr) noexcept {}, [](auto e) noexcept { e.get(); }));
458  static_assert(mi::Receiver<decltype(out6)>, "out6 not a receiver");
459  auto out7 = mi::MAKE(flow_receiver)(mi::on_done([]() {}));
460  static_assert(mi::Receiver<decltype(out7)>, "out7 not a receiver");
461 
462  auto out8 = mi::MAKE(flow_receiver)(
464  static_assert(mi::Receiver<decltype(out8)>, "out8 not a receiver");
465 
466  using Out0 = decltype(out0);
467 
468  auto proxy0 = mi::MAKE(flow_receiver)(out0);
469  static_assert(mi::Receiver<decltype(proxy0)>, "proxy0 not a receiver");
470  auto proxy1 = mi::MAKE(flow_receiver)(out0, mi::passDVF{});
471  static_assert(mi::Receiver<decltype(proxy1)>, "proxy1 not a receiver");
472  auto proxy2 = mi::MAKE(flow_receiver)(out0, mi::passDVF{}, mi::passDEF{});
473  static_assert(mi::Receiver<decltype(proxy2)>, "proxy2 not a receiver");
474  auto proxy3 = mi::MAKE(flow_receiver)(
475  out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
476  static_assert(mi::Receiver<decltype(proxy3)>, "proxy3 not a receiver");
477  auto proxy4 = mi::MAKE(flow_receiver)(
478  out0, [](auto d, auto v) { mi::set_value(d, v.get()); });
479  static_assert(mi::Receiver<decltype(proxy4)>, "proxy4 not a receiver");
480  auto proxy5 = mi::MAKE(flow_receiver)(
481  out0,
482  mi::on_value([](Out0&, auto v) { v.get(); }, [](Out0&, int) {}),
483  mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
484  ](Out0&, auto e) noexcept { e.get(); }));
485  static_assert(mi::Receiver<decltype(proxy5)>, "proxy5 not a receiver");
486  auto proxy6 = mi::MAKE(flow_receiver)(
487  out0, mi::on_error([](Out0&, std::exception_ptr) noexcept {}, [
488  ](Out0&, auto e) noexcept { e.get(); }));
489  static_assert(mi::Receiver<decltype(proxy6)>, "proxy6 not a receiver");
490  auto proxy7 = mi::MAKE(flow_receiver)(out0, mi::on_done([](Out0&) {}));
491  static_assert(mi::Receiver<decltype(proxy7)>, "proxy7 not a receiver");
492 
493  auto proxy8 = mi::MAKE(flow_receiver)(
494  out0, mi::passDVF{}, mi::passDEF{}, mi::passDDF{});
495  static_assert(mi::Receiver<decltype(proxy8)>, "proxy8 not a receiver");
496 
497  auto any2 = mi::any_flow_receiver<
498  std::exception_ptr,
499  std::ptrdiff_t,
500  std::exception_ptr,
501  int>(out0);
502  auto any3 = mi::any_flow_receiver<
503  std::exception_ptr,
504  std::ptrdiff_t,
505  std::exception_ptr,
506  int>(proxy0);
507 }
508 
510  auto in0 = mi::MAKE(flow_single_sender)();
511  static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
512  auto in1 = mi::MAKE(flow_single_sender)(mi::ignoreSF{});
513  static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
514  auto in2 = mi::MAKE(flow_single_sender)(mi::ignoreSF{}, mi::trampolineEXF{});
515  static_assert(mi::Sender<decltype(in2)>, "in2 not a sender");
516  auto in3 = mi::MAKE(flow_single_sender)(
517  [&](auto out) {
518  in0.submit(mi::MAKE(flow_receiver)(
519  std::move(out),
520  mi::on_value([](auto d, int v) { mi::set_value(d, v); })));
521  },
522  []() { return mi::trampoline(); });
523  static_assert(mi::Sender<decltype(in3)>, "in3 not a sender");
524 
525  auto out0 = mi::MAKE(flow_receiver)();
526  auto out1 = mi::MAKE(flow_receiver)(
527  out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
528  in3.submit(out1);
529 
530  auto any0 =
532  in0);
533 
534  static_assert(
535  mi::Executor<mi::executor_t<decltype(in0)>>,
536  "sender has invalid executor");
537 }
538 
540  auto in0 = mi::MAKE(flow_many_sender)();
541  static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
542  auto in1 = mi::MAKE(flow_many_sender)(mi::ignoreSF{});
543  static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
544  auto in2 = mi::MAKE(flow_many_sender)(mi::ignoreSF{}, mi::trampolineEXF{});
545  static_assert(mi::Sender<decltype(in2)>, "in2 not a sender");
546  auto in3 = mi::MAKE(flow_many_sender)(
547  [&](auto out) {
548  in0.submit(mi::MAKE(flow_receiver)(
549  std::move(out),
550  mi::on_value([](auto d, int v) { mi::set_value(d, v); })));
551  },
552  []() { return mi::trampoline(); });
553  static_assert(mi::Sender<decltype(in3)>, "in3 not a sender");
554 
555  auto out0 = mi::MAKE(flow_receiver)();
556  auto out1 = mi::MAKE(flow_receiver)(
557  out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
558  in3.submit(out1);
559 
560  auto any0 = mi::any_flow_many_sender<
561  std::exception_ptr,
562  std::ptrdiff_t,
563  std::exception_ptr,
564  int>(in0);
565 
566  static_assert(
567  mi::Executor<mi::executor_t<decltype(in0)>>,
568  "sender has invalid executor");
569 }
570 
571 TEST(CompileTest, Test) {}
void receiver_0_test()
Definition: CompileTest.cpp:43
auto v
void flow_single_sender_test()
auto on_value(Fns...fns) -> on_value_fn< Fns... >
Definition: boosters.h:262
detail::delegator< E > trampoline()
Definition: trampoline.h:261
void many_sender_test()
std::chrono::steady_clock::time_point now()
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
auto on_error(Fns...fns) -> on_error_fn< Fns... >
Definition: boosters.h:273
requires E e noexcept(noexcept(s.error(std::move(e))))
inline_constrained_executor_t inline_constrained_executor()
Definition: inline.h:51
void flow_receiver_1_test()
#define MAKE(x)
Definition: CompileTest.cpp:40
PUSHMI_INLINE_VAR constexpr detail::blocking_submit_fn blocking_submit
Definition: submit.h:389
void flow_many_sender_test()
void flow_receiver_n_test()
PUSHMI_INLINE_VAR constexpr detail::submit_at_fn submit_at
Definition: submit.h:387
void single_sender_test()
void receiver_1_test()
Definition: CompileTest.cpp:99
auto on_done(Fn fn) -> on_done_fn< Fn >
Definition: boosters.h:285
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
static set< string > s
void receiver_n_test()
void constrained_single_sender_test()
void time_single_sender_test()
inline_time_executor_t inline_time_executor()
Definition: inline.h:84
PUSHMI_INLINE_VAR constexpr detail::submit_after_fn submit_after
Definition: submit.h:388
char c
TEST(SequencedExecutor, CPUThreadPoolExecutor)