Files
2025-10-25 03:02:53 +03:00

47 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[basic.lookup.elab]
# 6 Basics [[basic]](./#basic)
## 6.5 Name lookup [[basic.lookup]](basic.lookup#elab)
### 6.5.6 Elaborated type specifiers [basic.lookup.elab]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2745)
If the [*class-key*](class.pre#nt:class-key "11.1Preamble[class.pre]") or enum keyword
in an [*elaborated-type-specifier*](dcl.type.elab#nt:elaborated-type-specifier "9.2.9.5Elaborated type specifiers[dcl.type.elab]") is followed by an [*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]") that is not followed by ::,
lookup for the [*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]") is type-only ([[basic.lookup.general]](basic.lookup.general "6.5.1General"))[.](#1.sentence-1)
[*Note [1](#note-1)*:
In general, the recognition of an [*elaborated-type-specifier*](dcl.type.elab#nt:elaborated-type-specifier "9.2.9.5Elaborated type specifiers[dcl.type.elab]") depends on the following tokens[.](#1.sentence-2)
If the [*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]") is followed by ::,
see [[basic.lookup.qual]](basic.lookup.qual "6.5.5Qualified name lookup")[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2758)
If the terminal name of the [*elaborated-type-specifier*](dcl.type.elab#nt:elaborated-type-specifier "9.2.9.5Elaborated type specifiers[dcl.type.elab]") is a qualified name,
lookup for it is type-only[.](#2.sentence-1)
If the name lookup does not find a previously declared [*type-name*](dcl.type.simple#nt:type-name "9.2.9.3Simple type specifiers[dcl.type.simple]"),
the [*elaborated-type-specifier*](dcl.type.elab#nt:elaborated-type-specifier "9.2.9.5Elaborated type specifiers[dcl.type.elab]") is ill-formed[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2765)
[*Example [1](#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]](dcl.type.elab "9.2.9.5Elaborated type specifiers"))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]](dcl.type.elab "9.2.9.5Elaborated type specifiers"))struct Base::Data; // error: cannot introduce a qualified type ([[dcl.type.elab]](dcl.type.elab "9.2.9.5Elaborated type specifiers"))struct Base::Datum; // error: Datum undefinedstruct Base::Data* pBase; // OK, refers to nested Data — *end example*]