Skip to content
New issue

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

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

Already on GitHub? # to your account

[FEATURE] add filter like algorithm. #96

Open
jehelset opened this issue Nov 19, 2024 · 2 comments
Open

[FEATURE] add filter like algorithm. #96

jehelset opened this issue Nov 19, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jehelset
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Sometimes it is nice to be able to filter out elements from a product-type, and work only with subset.

Describe the solution you'd like
A filter like algorithm that takes a product-type and a predicate, and removes elements for which the predicate returns false.

Describe alternatives you've considered
I instead used something like:

constexpr bool is_supported_thing(thing t){
  return some-expr-with-t;
}
inline constexpr auto supported_things = []{
  constexpr auto n = []{
    return std::ranges::count_if(all_things, &is_supported_thing);
  }();
  std::array<thing, n> t;
  std::ranges::copy_if(all_things, t.data(), &is_supported_thing);
  return t;
}();
@jehelset jehelset added the enhancement New feature or request label Nov 19, 2024
@jehelset
Copy link
Contributor Author

@jfalcou suggested https://godbolt.org/z/sYq4Pecxh as a workaround, which is pretty close.

@jfalcou
Copy link
Owner

jfalcou commented Nov 19, 2024

Just need to wrap it nicely I guess

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants