int8_t
int16_t
int32_t
int64_t
signed integer type with width of exactly 8, 16, 32 and 64 bits respectively
with no padding bits and using 2's complement for negative values
(provided if and only if the implementation directly supports the type)
Ну давайте поиграемся.
Что будет выведено вот на это:
std::cout << "int16_t: \n"
<< static_cast<int16_t>(00) << '\n'
<< static_cast<int16_t>(48) << '\n'
<< static_cast<int16_t>(65) << '\n'
<< std::endl;
Правильный ответ:
```
int16_t:
0
48
65
```
А вот на это?
std::cout << "int64_t: \n"
<< static_cast<int64_t>(00) << '\n'
<< static_cast<int64_t>(48) << '\n'
<< static_cast<int64_t>(65) << '\n'
<< std::endl;
Правильный ответ:
```
int64_t:
0
48
65
```
А вот на это?
std::cout << "int8_t: \n"
<< static_cast<int8_t>(00) << '\n'
<< static_cast<int8_t>(48) << '\n'
<< static_cast<int8_t>(65) << '\n'
<< std::endl;
Правильный ответ:
```
int8_t:
0
A
```
А все почему?
Потому что идите все нахер, int8_t - это char.
Особенно это приятно, когда у вас из логов пропадает что-то такое:
enum class Direction : int8_t {
LEFT, RIGHT, UP, DOWN
};
// ...
std::cout << static_cast<int8_t>(Direction::LEFT)
<< std::endl;
using Int = std::underlying_type_t<Direction>;
std::cout << static_cast<Int>(Direction::LEFT)
<< std::endl;
Ну вот и нахрен так жить?