Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-04 14:13:33


Ivan Matek wrote:
> On Wed, Dec 4, 2024 at 2:36 PM Claudio DeSouza via Boost <
> boost_at_[hidden]> wrote:
>
> > There has been some discussion about this and the consensus is that
> > `uint8_t` is a better option than `std::byte` as the former represents
> > a determinate number of bytes (
> > https://isocpp.org/wiki/faq/intrinsic-types#bits-per-byte). So
> > `span<const uint8_t>, and `span<uint8_t>` for immutable and mutable
> bytes respectively.
> >
> >
> I presume think static_assert for CHAR_BIT value is enough, I am not aware of
> anybody using systems where this is not true, despite what faq says...
> but I must admit I am not familiar with all weird archs so I could be wrong

Using uint8_t is equivalent to asserting that CHAR_BIT is 8.

In practice, uint8_t, when defined, is always unsigned char, except when it's
`char` on platforms that strive to make your life interesting. But that's
non-conforming.

There's an attempt to make CHAR_BIT == 8 required

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3477r0.html

but it might be slightly ahead of its time because a few holdover platforms
with CHAR_BIT == 32 still remain in use.

(On these, uint8_t is a compile time error.)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk