Even setting the size of an enum is not enough to be able to assign it to a variable of the same size (http://coliru.stacked-crooked.com/a/edd287393f172abd):
#include <iostream>
#include <cstdint>
enum class Command : uint8_t
{
CMD1 = 0x48,
CMD2 = 0x97,
CMD3 = 0x98,
CMD4 = 0x92
};
int main()
{
uint8_t test = Command::MACHINE_INFO;
}
Is there a way I could use the enum to initialize my uint8_t variable without casting it?