You are violating [basic.scope.pdecl]/6 , which states:
The declaration point of the class first declared in the specified type specifier is as follows:
- to declare a form
class-key attribute-specifier-seqopt identifier ;
the identifier is declared as the class name in the scope containing the declaration, otherwise
- for the specified type specifier type
class-key identifier
if the specified type specifier is used in the decl-specifier-seq or declaration parameter function defined in the namespace area, the identifier is declared as the class name in the namespace, contains a declaration; otherwise, except for declaring a friend, the identifier is declared in the smallest namespace or block area containing the declaration. [Note. These rules also apply within patterns. - end note] [Note: Other forms of the specified type specifier do not declare a new name, and therefore must reference an existing type name. See 3.4.4 and 7.1.6.3. - final note]
- you are not creating an anonymous type variable
- you are not creating a type
There is another example in the standard (in [basic.def]/2 ) that proves that your example does not comply with the standard:
struct S { int a; int b; }; // defines S, S::a, and S::b struct X { // defines X int x; // defines non-static data member x static int y; // declares static data member y X(): x(0) { } // defines a constructor of X }; int X::y = 1; // defines X::y enum { up, down }; // defines up and down namespace N { int d; } // defines N and N::d namespace N1 = N; // defines N1 X anX; // defines anX
In your example, nothing is defined (except for the anonymous structure, which fields cannot be accessed).
Note the exclusion from the listing, because this case introduces two values ββto use.
BΠoviΡ 30 Oct '12 at 12:56 2012-10-30 12:56
source share