Is std::byte well defined?

Essentially there is special wording all around the c++17 draft standard that gives std::byte the same properties with regard to aliasing as char and unsigned char. To give you an example, the the C++17 standard, [basic.lval] p8 states: If a program attempts to access the stored value of an object through a glvalue of other … Read more

Does a pointer to std::byte have the same aliasing relaxations as char*?

From the current Standard draft ([basic.types.general]/2): For any object (other than a potentially-overlapping subobject) of trivially copyable type T, whether or not the object holds a valid value of type T, the underlying bytes ([intro.memory]) making up the object can be copied into an array of char, unsigned char, or std​::​byte ([cstddef.syn]). If the content … Read more

What is the purpose of std::byte?

You are perhaps misunderstanding things. byte is very much intended for “accessing memory”. You are intended to use the type when the storage is just a sequence of bytes rather than an array of characters. Iostream types cannot be specialized with byte, since they’re designed around characters as their interface. That is, they do not … Read more

tech