Skip to content

Conversation

@elbeno
Copy link
Contributor

@elbeno elbeno commented Feb 11, 2025

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.

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.
@elbeno elbeno force-pushed the bitset-transform-reduce branch from 61c1980 to 7fc489b Compare February 11, 2025 18:51
@lukevalenty lukevalenty merged commit e6b6404 into intel:main Feb 11, 2025
32 checks passed
@elbeno elbeno deleted the bitset-transform-reduce branch February 12, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants