c++ - C++11 Accessing Unscoped Enumerators with Qualified Name -
I have a question about the words of the C ++ 11 standard because I have not had to dig it in the past It was found that I was confused with the topic of unsampled nimics (confusing unrealistic).
I recently had a code in a code review that was using an unsigned enum, but to access the calculator using fully qualified names it:
Some entities {Enuma, ...}; Zero foo () {SomeEnum x = SomeEnum :: EnumA; }
I was convinced that this was not working and some Annam had to be an ANU class for this behavior, but to ensure it adequately compiled it properly Happened.
Seeing in the C ++ 11 standard, I first thought that the standard agreed with me:
§ 7.2 Intellectuals announcements: Each enum -name and each unscoped calculator has been declared in the realm, which is immediately declared in the enumeration of each test calculator within the scope of calculation.
It appears to me to reveal that the unsigned enumerator is declared immediately within the scope of the enumeration, not to mention that they are also declared in the computing area. .
However, a little further down, there is an example in the standard that shows how to reach an unsocked enumerator using a fully qualified name.
A small description of searching on Goggle and SED has given me a small space which believes that the standard now allows a fully qualified name but there is not much discussion. Is this just a description of weak words on the basis of example, or am I missing?
Again, this earth is not going to break, but I hope someone can set me straight on the standard of my reading and I can learn something which can be useful in the future.
The quote that you are looking for is section 5.1
The primary expression is , in the parameter 10 says:
A nested-name-specificifier that represents an enumeration (7.2), that computation After the name of a calculator, there is a qualification-id that refers to the calculator. The result is the calculator. The type of result is the type of calculation. The result is a private one.
This does not restrict access to the scanned enumeration and therefore the example in section 7.2
Enumerating Announcements :
directions (left = 'l', right = 'r'}; zero g () {direction d; // ok d = left; // fine d = direction :: true; // ok}
is fully compatible. This section is compatible with 3.4.3
qualified name lookup which says:
A class or name space should be referenced after the name of the member or enumerator It is: Scope resolution operator (5.1) applies to the nested-name-specifier, which shows its class, namespace, or calculation. [...]
and:
A nested-name-specificifier will represent the prefix name, which designates an enumeration type, to calculate a calculator.
Again, to limit this behavior Nothing is scotched for the enumeration.
But as long as they are Pram Do not conflict with the pathetic stories, then they should be considered a good guideline.
Comments
Post a Comment