-
Notifications
You must be signed in to change notification settings - Fork 444
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
Common: Add flags enum helper class #13778
base: dev
Are you sure you want to change the base?
Conversation
REQUEST FOR PRODUCTION RELEASES:
This will add The following labels are available |
c82f222
to
a59f22f
Compare
cefee92
to
fb2d69a
Compare
987f4b8
to
ce57614
Compare
Error while checking build/O2/fullCI for ce57614 at 2025-01-02 10:25:
Full log here. |
Hi @sawenzel would this be interesting to add? I have a few scenarios in mind where, in the future, managing multiple boolean flags (e.g., for enabling or disabling algorithm features) could become cumbersome. In such cases, a bitset could be a viable alternative. However, I’d like to make it possible to set these features via their names (also because I think it is mind-boggling to remember which number sets which bit). |
In a previous iteration this was done via macros, now this became a helper class promoting any enum to a functioning constexpr flags class (very close to std::bitset).
Also enum reflection was added. Where one can print the enum in a 'pretty' way:
but also allowing to set bits via their name:
flags.set("Flag1|TestEnum::Flag2 | Flag4 ");
The class has only one data member, e.g. the underlying type of the enum, so streaming should be straightforward to add if needed.