3.2 KiB
[basic.lookup.elab]
6 Basics [basic]
6.5 Name lookup [basic.lookup]
6.5.6 Elaborated type specifiers [basic.lookup.elab]
If the class-key or enum keyword in an elaborated-type-specifier is followed by an identifier that is not followed by ::, lookup for the identifier is type-only ([basic.lookup.general]).
[Note 1:
In general, the recognition of an elaborated-type-specifier depends on the following tokens.
If the identifier is followed by ::, see [basic.lookup.qual].
â end note]
If the terminal name of the elaborated-type-specifier is a qualified name, lookup for it is type-only.
If the name lookup does not find a previously declared type-name, the elaborated-type-specifier is ill-formed.
[Example 1: struct Node {struct Node* Next; // OK, refers to injected-class-name Nodestruct Data* Data; // OK, declares type Data at global scope and member Data};
struct Data {struct Node* Node; // OK, refers to Node at global scopefriend struct ::Glob; // error: Glob is not declared, cannot introduce a qualified type ([dcl.type.elab])friend struct Glob; // OK, refers to (as yet) undeclared Glob at global scope./* ... */};
struct Base {struct Data; // OK, declares nested Datastruct ::Data* thatData; // OK, refers to ::Datastruct Base::Data* thisData; // OK, refers to nested Datafriend class ::Data; // OK, global Data is a friendfriend class Data; // OK, nested Data is a friendstruct Data { /* ... */ }; // Defines nested Data};
struct Data; // OK, redeclares Data at global scopestruct ::Data; // error: cannot introduce a qualified type ([dcl.type.elab])struct Base::Data; // error: cannot introduce a qualified type ([dcl.type.elab])struct Base::Datum; // error: Datum undefinedstruct Base::Data* pBase; // OK, refers to nested Data â end example]