@@ -44,11 +44,11 @@ Actions are added to the flow inside a component's `cib::config`.
44
44
struct morning {
45
45
constexpr auto config = cib::config(
46
46
cib::extend<MorningRoutine>(
47
- WAKE_UP >>
48
- selfcare::SHOWER >>
49
- selfcare::GET_DRESSED >>
50
- food::MAKE_COFFEE >>
51
- food::DRINK_COFFEE));
47
+ + WAKE_UP >>
48
+ + selfcare::SHOWER >>
49
+ + selfcare::GET_DRESSED >>
50
+ + food::MAKE_COFFEE >>
51
+ + food::DRINK_COFFEE));
52
52
};
53
53
----
54
54
@@ -58,6 +58,17 @@ a shower. The flow library will order actions in a flow to respect these
58
58
dependencies. The actions will be executed in an order that respects all given
59
59
dependencies.
60
60
61
+ The unary `+` operator is used to explicitly add an action to the
62
+ flow. Without the unary `+` operator an action is just a reference.
63
+ A compile-time error will be triggered if an action is referenced without ever
64
+ being explicitly added to the flow. If an action is added under a compile-time
65
+ or runtime conditional, and the conditional is false, then it is as if the
66
+ action was never added at all.
67
+
68
+ The behavior of the unary `+` operator ensures that merely referencing an
69
+ action to create an ordering dependency doesn't unintentionally add the action
70
+ to the flow.
71
+
61
72
If we only use the `morning` component in our project, the `MorningRoutine` flow
62
73
graph would look like the following:
63
74
@@ -93,11 +104,11 @@ struct childcare {
93
104
constexpr auto config = cib::config(
94
105
cib::extend<MorningRoutine>(
95
106
food::MAKE_COFFEE >> // this step exists in the MorningRoutine flow
96
- PACK_SCHOOL_LUNCHES >> // new
107
+ + PACK_SCHOOL_LUNCHES >> // new
97
108
food::DRINK_COFFEE >> // existing
98
- food::MAKE_BREAKFAST >> // new
99
- food::EAT_BREAKFAST >> // new
100
- SEND_KIDS_TO_SCHOOL)); // new
109
+ + food::MAKE_BREAKFAST >> // new
110
+ + food::EAT_BREAKFAST >> // new
111
+ + SEND_KIDS_TO_SCHOOL)); // new
101
112
};
102
113
----
103
114
@@ -140,7 +151,7 @@ struct exercise {
140
151
constexpr auto config = cib::config(
141
152
cib::extend<MorningRoutine>(
142
153
morning::WAKE_UP >>
143
- RIDE_STATIONARY_BIKE >>
154
+ + RIDE_STATIONARY_BIKE >>
144
155
selfcare::SHOWER));
145
156
};
146
157
----
@@ -321,7 +332,47 @@ namespace example_component {
321
332
constexpr auto config = cib::config(
322
333
cib::extend<MyFlow>(
323
334
// no order requirement between these actions
324
- SOME_ACTION && SOME_OTHER_ACTION));
335
+ +SOME_ACTION && +SOME_OTHER_ACTION));
336
+ }
337
+ ----
338
+
339
+ ==== unary `operator+`
340
+
341
+ Explicitly add an action to the flow. Actions used in flow extensions without
342
+ the unary `+` will be treated as references only and will not be added to the
343
+ flow at that location. It is a compilation error if an action is not added
344
+ with a unary `+` in exactly one location in the overall config.
345
+
346
+ Actions can be added and ordered all at once:
347
+
348
+ [source,cpp]
349
+ ----
350
+ namespace example_component {
351
+ constexpr auto config = cib::config(
352
+ cib::extend<MyFlow>(
353
+ // Add both actions and create an ordering between them.
354
+ +SOME_ACTION >> +SOME_OTHER_ACTION));
355
+ }
356
+ ----
357
+
358
+ Actions can also be added and ordered seperately:
359
+
360
+ [source,cpp]
361
+ ----
362
+ namespace other_component {
363
+ constexpr auto INIT_SOMETHING = ...
364
+
365
+ constexpr auto config = cib::config(
366
+ cib::extend<MyFlow>(+INIT_SOMETHING));
367
+ }
368
+
369
+ namespace example_component {
370
+ constexpr auto DO_A_THING = ...
371
+
372
+ constexpr auto config = cib::config(
373
+ cib::extend<MyFlow>(
374
+ other_component::INIT_SOMETHING >>
375
+ +DO_A_THING));
325
376
}
326
377
----
327
378
0 commit comments