type_safe
type_safe copied to clipboard
flag_set iterator(s) and/or for_each(flag_set<E>, [](E){})
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); }
);
}
If you be willing to write something, I'm happy for a PR.
In case someone works on this, I think range syntax would also be nice:
for (auto f : some_flag_set) {
do_something_with(f);
}