Commit 61c1980
committed
✨ Add
Problem:
- It is relatively common to want to do for_each on a bitset, but also capture
whether or not the action succeeded at all, e.g. when handling a message with
an indexed handler.
Solution:
- Add `transform_reduce` on bitset.
Note:
- Both `for_each` and `transform_reduce` are applicable variadically, however
this is not yet implemented. But this is the reason that the bitset is the
final argument.
- There are some differences (for the better) from the `std::transform_reduce`
API.
- The transform function comes before the reduction function.
`std::transform_reduce` is confusing, because the transform happens first
but is given second.
- The type of the `init` value can be easily given in a template argument;
this is helpful for avoiding warnings when passing `0` (an `int`) to
accumulate potentially larger integral types.transform_reduce on bitset1 parent 62b9868 commit 61c1980
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
120 | 138 | | |
121 | 139 | | |
122 | 140 | | |
| |||
421 | 439 | | |
422 | 440 | | |
423 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
424 | 455 | | |
425 | 456 | | |
426 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
334 | 348 | | |
335 | 349 | | |
336 | 350 | | |
| |||
0 commit comments