Is is possible to prevent explicit enum storage size conversions? I tried overloading = but this does not seem to work on primitive types.
enum GlobalSettingTableType : std::uint16_t
{
first = 0,
second = 1,
other = 1000 // out of range for uint8_t
};
GlobalSettingTableType test = GlobalSettingTableType::other;
std::uint16_t copyOK = test;
std::uint8_t copyfail = test; // Should not compile
enum classwouldn't allow implicit conversions at all. If you need more control than this, make a class.uint16_tto an `` uint8_t` gives the expected warning about a possible value change); however, if you were to switch toenum class-- which is recommended anyway for type-safety -- you wouldn't even be able to assign to other types without a cast.std::uint8_t copyfail{test};