$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2025-06-11 15:20:15
On 11 Jun 2025 17:47, Ivan Matek wrote:
>
> On Wed, Jun 11, 2025 at 4:05â¯PM Andrey Semashev via Boost
> <boost_at_[hidden] <mailto:boost_at_[hidden]>> 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 <https://godbolt.org/z/WfGx76vxo>
It would work, but it also would not enable bitwise operations on the
atomic. And regarding integers, we already have a strong typedef in the
language, it is called enums. :)