Is it safe to reinterpret_cast an enum class variable to a reference of the underlying type?
You might want to overload operator ++ for your enum if you really want to iterate its values: Foo& operator++( Foo& f ) { using UT = std::underlying_type< Foo >::type; f = static_cast< Foo >( static_cast< UT >( f ) + 1 ); return f; } and use for (Foo foo = Foo::First; foo <= … Read more