How to use something like `std::basic_istream<std::byte>`

Don't.

Whether you're operating in "text mode" or "binary mode", what you are still doing fundamentally is acting on characters.

std::byte is not for this purpose, and that's why it does not have these features. Indeed, it was deliberately introduced not to have them!

enum class byte : unsigned char {} ; (since C++17)

std::byte is a distinct type that implements the concept of byte as specified in the C++ language definition.

Like char and unsigned char, it can be used to access raw memory occupied by other objects (object representation), but unlike those types, it is not a character type and is not an arithmetic type. A byte is only a collection of bits, and only bitwise logic operators are defined for it.

http://en.cppreference.com/w/cpp/types/byte


Did anyone make this kind of thing work already?

No, everyone deliberately didn't, as explored above.

Use char or unsigned char, as we have done for decades!

Tags:

C++

Io

C++17

Std