Conversion from uint8_t
Closed this issue · 2 comments
own2pwn commented
Hi, there's a problem with conversion from uint8_t
on macOS Catalina, 10.15.4 (19E287)
struct simple {
uint8_t id;
}
Viven that your model has such a field, you won't be able to initialize it correctly because of stream's eof
would be false.
Idk, maybe the problem is on macOS(clang) only.
dmitigr commented
Hi!
In fact, uint8_t
is usually unsigned char
. The behavior of operator>>
for unsigned char
is slightly different from other overloads of operator>>
-- it doesn't set eofbit
after extracting a character that is the last character of the stream. (Please, see https://en.cppreference.com/w/cpp/io/basic_istream/operator_gtgt2)
You can convert like this static_cast<uint8_t>(pgfe::to<char>(foo))
.