Код: Выделить всё
#include
#include
#include
static constexpr int32_t KEYBOARD_KEY_A = 65;
static constexpr int32_t KEYBOARD_KEY_D = 68;
static constexpr int32_t KEYBOARD_KEY_S = 83;
static constexpr int32_t KEYBOARD_KEY_W = 87;
enum class Movement : uint8_t
{
Forward,
Backward,
Left,
Right
};
static std::optional KeyToMovement(int32_t keycode)
{
switch (keycode)
{
case KEYBOARD_KEY_W:
return Movement::Forward;
case KEYBOARD_KEY_S:
return Movement::Backward;
case KEYBOARD_KEY_A:
return Movement::Left;
case KEYBOARD_KEY_D:
return Movement::Right;
default:
return std::nullopt;
}
std::unreachable();
}
int main()
{
KeyToMovement(KEYBOARD_KEY_A);
}
Код: Выделить всё
(34) : error C2220: the following warning is treated as an error
(34) : warning C4702: unreachable code
Подробнее здесь: https://stackoverflow.com/questions/798 ... under-msvc
Мобильная версия