c++ - Why can't we use nested type through class-member-access expression? -



c++ - Why can't we use nested type through class-member-access expression? -

i'm trying understand why can't utilize nested type through class-member-access expression. instance, have next class:

struct u { struct { static int v; int a; }; struct b { int b; }; }; u a; typedef a.a t; //'a' not name type int main() { std::cout << typeid(a.a).hash_code(); //invalid utilize of 'struct u::a' struct a.a b; //trying declare variable of type u::a //error: expected unqualified-id before '.' token a.a b; //the same above //error: expected unqualified-id before '.' token a.a.v = 5; //error: expected unqualified-id before '.' token }

demo

the standard says:

section n3797::5.2.5/2 [expr.ref]

for first alternative (dot) first look shall have finish class type. sec alternative (arrow) first look shall have pointer finish class type. look e1->e2 converted equivalent form (*(e1)).e2; remainder of 5.2.5 address first alternative (dot).in either case, id-expression shall name fellow member of class or of 1 of base of operations classes.

whereas, section n3797::9.2/1 [class.mem] gives definition of class member:

members of class info members, fellow member functions (9.3), nested types, , enumerators.

so can't see restriction such usage of nested type. why not?

look farther downwards in [expr.ref]

(4.4) if e2 nested type, look e1.e2 ill-formed.

c++ types

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -