I want to understand the situation related to uint8_t vs char, portability, bit manipulation, best practices, state of affairs, etc. Do you know a good read on this topic?
I want to do byte-IO. But, of course, char has a more complex and subtle definition than uint8_t; which, I believe, was one of the reasons for introducing the stdint header.
However, I had problems using uint8_t in several cases. A few months ago once, because iostreams are not defined for uint8_t. Isn't there a C ++ library that does true-byte-by-IO, i.e. read and write uint8_t? If not, I assume there is no demand for it. Why?
My last headache is related to the failure to compile this code:
uint8_t read(decltype(cin) & s)
{
char c;
s.get(c);
return reinterpret_cast<uint8_t>(c);
}
error: invalid cast from type 'char' to type 'uint8_t {aka unsigned char}'
Why a mistake? How to do it?