
11 Jun
2025
11 Jun
'25
10:15 p.m.
On Wed, Jun 11, 2025 at 1:34 AM Andrey Semashev via Boost < boost@lists.boost.org> wrote:
Hi,
There were quite a few times when I wanted to use bitwise operations on atomic<enum>, where the enum lists a number of flags that could be combined with bitwise AND, OR and XOR.
May I ask a bit more about motivation? More precisely why you prefer this over just using unsigned integers for flag? If you are worried about uniqueness of set bit it can be checked at compile time, e.g. something like this: https://godbolt.org/z/xqG866M8h (did not properly test this, so it may have bugs, but this is the idea). I like "scope" for flags(e,g, Color in Color::Red) but that can be done with namespaces, i.e. namespace Color{ constexpr uint32_t Red ... ,