I want strong enum types. C++0x has this feature but unfortunately they also require explicit scoping:
enum class E {e1, e2, e3};
E x = E::e1; //OK
E y = e1; //error
Sometimes this is desirable, but sometimes it’s just unnecessarily verbose. The identifiers might be unique enough by themselves or the enum might already be nested inside a class or namespace.
So I’m looking for a workaround. What would be the best way to declare the enum values also in the surrounding scope?
If you want the values visible in the surrounding scope, just add a couple of constants: