I have a question about the wording of the C++11 standard as I have not had to dig into it frequently in the past and recently found myself confused on the (admittedly unimportant) topic of unscoped enums.
I recently came across some code in a code review that was using an unscoped enum but accessing the enumerators using fully qualified names, like this:
enum SomeEnum
{
EnumA,
...
};
void foo()
{
SomeEnum x = SomeEnum::EnumA;
}
I was certain that this didn't work and that SomeEnum had to be an enum class for this behavior, but, sure enough, it compiled cleanly.
Peeking into the C++11 standard, I at first thought that the standard agreed with me:
ยง 7.2 Enumeration Declarations: Each enum-name and each unscoped enumerator is declared in the scope that immediately contains the enum-specifier. Each scoped enumerator is declared in the scope of the enumeration.
This appears to me to indicate that unscoped enumerators are declared only at the immediately containing scope of the enum itself. It doesn't mention that they are also declared at the enumeration scope.
However, a little further down, the standard does include an example that shows accessing an unscoped enumerator using the fully qualified name.
A quick bit of googling and searching on SO gave me a small number of places that assert that the standard does now allow the fully qualified name, but there isn't much discussion. Is this just weak wording in the spec that is clarified by the example, or is there something else I'm missing?
Again, this isn't earth shattering, but I'm hoping someone can set me straight on my reading of the standard and I can learn something that may be useful in a future situation.