If I run this code:
std::cout << static_cast(65);
It will output:
A
Which
Posting an answer as there is some misinformation in comments.
The uint8_t
may or may not be a typedef for char
or unsigned char
. It is also possible for it to be an extended integer type (and so, not a character type).
Compilers may offer other integer types besides the minimum set required by the standard (short
, int
, long
, etc). For example some compilers offer a 128-bit integer type.
This would not "conflict with C" either, since C and C++ both allow for extended integer types.
So, your code has to allow for both possibilities. The suggestion in comments of using unary +
would work.
Personally I think it would make more sense if the standard required uint8_t
to not be a character type, as the behaviour you have noticed is unintuitive.