I've been experimenting with the enum class feature of C++ and successfully got the
Код: Выделить всё
++Код: Выделить всё
enum class counter_t : uint8_t {VAL1 = 0, VAL2, VAL3, VAL4, END};
inline counter_t operator ++ (counter_t c, int) {
counter_t c2;
if (c == counter_t::END) {
c2 = counter_t::VAL1;
}
else {
c2 = (counter_t)((uint8_t)c + 1);
}
return (c2);
}
int main(void) {
volatile counter_t x = counter_t::VAL1;
x = x++;
x++;
while(1) {
// Do stuff
}
}
Источник: https://stackoverflow.com/questions/316 ... class-type
Мобильная версия