I\'ve seen reinterpret_cast used to apply incrementation to enum classes, and I\'d like to know if this usage is acceptable in standard C++.
reinterpret_cast
enu
It is safe as long as it casts to the exact underlying type of the enum.
If the underlying type of the enum class changes that ++reinterpret_cast(foo) breaks silently.
++reinterpret_cast(foo)
A safer version:
foo = static_cast(static_cast::type>(foo) + 1);
Or,
++reinterpret_cast::type&>(foo);