Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add transform_reduce on bitset #190

Merged
merged 1 commit into from
Feb 11, 2025

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