Enum entered using ad

I am trying to understand an enumeration that is defined using nested qualifiers. What the standard says: N4296:7.2/4 [dcl.enum] :

If the last key is a nested specifier, the enum-specifier must refer to an enumeration that was previously declared directly in the class or namespace to which the nested specifier name (i.e., is not inherited and is not entered using the declaration declaration) , and the enumeration qualifier should appear in the namespace containing the previous declaration.

OK, why does the following example work?

 #include <iostream> namespace A { namespace B { enum E : int; } } namespace C { using A::B::E; } enum C::E : int { x = 2 }; int main() { } 

Demo

In namescape C we declared enum E with a declaration, and then referred to it with an enumeration definition. The compiler may have made a mistake, but it is not. What was wrong, where was the misunderstanding?

+5
source share
1 answer

Clearly, for the reasons you give, this is a compiler error.
Interestingly, Clang 3.5.0 and GCC 4.9 accept the program.

+2
source

Source: https://habr.com/ru/post/1209944/


All Articles