
On Wed, Jun 11, 2025 at 4:05 PM Andrey Semashev via Boost < boost@lists.boost.org> wrote:
If you have atomic<uint32_t> in your code then it isn't clear what this atomic value is about. It may be a counter, or an index, or a bit mask, or it may be something else entirely. If it is a bit mask, which bits are used and what meaning do they have. You can probably infer this information from the surrounding code and comments, but I would rather prefer atomic<enum>, where the enum part immediately gives you that information. It is enough to just follow to the enum definition to see which values are valid and whether it is a bit mask.
I agree with your concern about readability, but would strong typedef work here? I am not an atomic expert, but it seems wrapping uint32_t in a simple struct does not destroy lockfree property of atomic. https://godbolt.org/z/WfGx76vxo