Having carefully read the message about the tragedy in C ++, reading the message that it std::byte
was added in C ++ 17. I have some problems as an initial reading, since it uses unsigned char
so that it can avoid complications with strict alias rules.
My biggest problem: how does it work on platforms where CHAR_BIT
not 8? I worked on platforms where CHAR_BIT
- 16 or 32 (usually DSP). Given that it is std::byte
designed to work with "byte-oriented access to memory," and most people understand bytes to indicate an octet (rather than the size of the base character type), how this will work for people who expect it to be addressed continuously 8 bits of memory?
I already see people who simply assume that it CHAR_BIT
is 8 (and not in the evening, knowing that it CHAR_BIT
exists ...). The type called std::byte
is likely to lead to even more confusion with people.
I suppose I expected them to introduce a type that allows sequential addressing / access to sequential octets for all cases. There are many octet-oriented protocols where it would be useful to have a library or type guaranteed access to memory one octet at a time on all platforms, regardless of what CHAR_BIT
is equal on that platform.
I definitely understand that I want it to be well-specified that something is used as a sequence of bytes rather than a sequence of characters, but this does not seem to be as useful as many other things can be.