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

flag_set iterator(s) and/or for_each(flag_set<E>, [](E){}) #100

Open
ehoeks opened this issue May 23, 2019 · 2 comments · May be fixed by #114
Open

flag_set iterator(s) and/or for_each(flag_set<E>, [](E){}) #100

ehoeks opened this issue May 23, 2019 · 2 comments · May be fixed by #114

Comments

@ehoeks
Copy link

ehoeks commented May 23, 2019

As many programmers I sometimes need to do some work for all flags set in an flag_set.

Can we add an type_safe way to iterate over all 'set' flags in an flag_set?
e.g.

enum class my_enum; // some flag_set compatible enum class

void do_something_with(my_enum e);

{
  type_safe::flag_set<my_enum> some_flag_set();

  type_safe::for_each(
    some_flag_set,
    [](f){ do_something_with(f); }
  );
}
@ehoeks ehoeks changed the title flag_set iterator(s) and/or foreach(flag_set<E>, [](E){}) flag_set iterator(s) and/or for_each(flag_set<E>, [](E){}) May 23, 2019
@foonathan
Copy link
Owner

If you be willing to write something, I'm happy for a PR.

@NikolausDemmel
Copy link

In case someone works on this, I think range syntax would also be nice:

  for (auto f : some_flag_set) {
    do_something_with(f);
  }

@Neargye Neargye linked a pull request Jun 23, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants