From Jason Turner

[namespace.qual]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpd05mp5d9/{from.md → to.md} +17 -88
tmp/tmpd05mp5d9/{from.md → to.md} RENAMED
@@ -1,30 +1,16 @@
1
  #### Namespace members <a id="namespace.qual">[[namespace.qual]]</a>
2
 
3
- If the *nested-name-specifier* of a *qualified-id* nominates a namespace
4
- (including the case where the *nested-name-specifier* is `::`, i.e.,
5
- nominating the global namespace), the name specified after the
6
- *nested-name-specifier* is looked up in the scope of the namespace. The
7
- names in a *template-argument* of a *template-id* are looked up in the
8
- context in which the entire *postfix-expression* occurs.
9
 
10
- For a namespace `X` and name `m`, the namespace-qualified lookup set
11
- S(X, m) is defined as follows: Let S'(X, m) be the set of all
12
- declarations of `m` in `X` and the inline namespace set of `X`
13
- [[namespace.def]] whose potential scope [[basic.scope.namespace]] would
14
- include the namespace in which `m` is declared at the location of the
15
- *nested-name-specifier*. If S'(X, m) is not empty, S(X, m) is S'(X, m);
16
- otherwise, S(X, m) is the union of S(Nᵢ, m) for all namespaces Nᵢ
17
- nominated by *using-directive*s in `X` and its inline namespace set.
18
-
19
- Given `X::m` (where `X` is a user-declared namespace), or given `::m`
20
- (where X is the global namespace), if S(X, m) is the empty set, the
21
- program is ill-formed. Otherwise, if S(X, m) has exactly one member, or
22
- if the context of the reference is a *using-declaration*
23
- [[namespace.udecl]], S(X, m) is the required set of declarations of `m`.
24
- Otherwise if the use of `m` is not one that allows a unique declaration
25
- to be chosen from S(X, m), the program is ill-formed.
26
 
27
  [*Example 1*:
28
 
29
  ``` cpp
30
  int x;
@@ -78,11 +64,11 @@ void h()
78
  }
79
  ```
80
 
81
  — *end example*]
82
 
83
- [*Note 1*:
84
 
85
  The same declaration found more than once is not an ambiguity (because
86
  it is still a unique declaration).
87
 
88
  [*Example 2*:
@@ -105,11 +91,11 @@ namespace BC {
105
  using namespace C;
106
  }
107
 
108
  void f()
109
  {
110
- BC::a++; // OK: S is { `A::a`, `A::a` }
111
  }
112
 
113
  namespace D {
114
  using A::a;
115
  }
@@ -119,11 +105,11 @@ namespace BD {
119
  using namespace D;
120
  }
121
 
122
  void g()
123
  {
124
- BD::a++; // OK: S is { `A::a`, `A::a` }
125
  }
126
  ```
127
 
128
  — *end example*]
129
 
@@ -148,26 +134,21 @@ namespace B {
148
  using namespace A;
149
  }
150
 
151
  void f()
152
  {
153
- A::a++; // OK: a declared directly in A, S is { `A::a` }
154
- B::a++; // OK: both A and B searched (once), S is { `A::a` }
155
- A::b++; // OK: both A and B searched (once), S is { `B::b` }
156
- B::b++; // OK: b declared directly in B, S is { `B::b` }
157
  }
158
  ```
159
 
160
  — *end example*]
161
 
162
- During the lookup of a qualified namespace member name, if the lookup
163
- finds more than one declaration of the member, and if one declaration
164
- introduces a class name or enumeration name and the other declarations
165
- introduce either the same variable, the same enumerator, or a set of
166
- functions, the non-type name hides the class or enumeration name if and
167
- only if the declarations are from the same namespace; otherwise (the
168
- declarations are from different namespaces), the program is ill-formed.
169
 
170
  [*Example 4*:
171
 
172
  ``` cpp
173
  namespace A {
@@ -188,57 +169,5 @@ namespace C {
188
  }
189
  ```
190
 
191
  — *end example*]
192
 
193
- In a declaration for a namespace member in which the *declarator-id* is
194
- a *qualified-id*, given that the *qualified-id* for the namespace member
195
- has the form
196
-
197
- ``` bnf
198
- nested-name-specifier unqualified-id
199
- ```
200
-
201
- the *unqualified-id* shall name a member of the namespace designated by
202
- the *nested-name-specifier* or of an element of the inline namespace set
203
- [[namespace.def]] of that namespace.
204
-
205
- [*Example 5*:
206
-
207
- ``` cpp
208
- namespace A {
209
- namespace B {
210
- void f1(int);
211
- }
212
- using namespace B;
213
- }
214
- void A::f1(int){ } // error: f1 is not a member of A
215
- ```
216
-
217
- — *end example*]
218
-
219
- However, in such namespace member declarations, the
220
- *nested-name-specifier* may rely on *using-directive*s to implicitly
221
- provide the initial part of the *nested-name-specifier*.
222
-
223
- [*Example 6*:
224
-
225
- ``` cpp
226
- namespace A {
227
- namespace B {
228
- void f1(int);
229
- }
230
- }
231
-
232
- namespace C {
233
- namespace D {
234
- void f1(int);
235
- }
236
- }
237
-
238
- using namespace A;
239
- using namespace C::D;
240
- void B::f1(int){ } // OK, defines A::B::f1(int)
241
- ```
242
-
243
- — *end example*]
244
-
 
1
  #### Namespace members <a id="namespace.qual">[[namespace.qual]]</a>
2
 
3
+ Qualified name lookup in a namespace N additionally searches every
4
+ element of the inline namespace set of N [[namespace.def]]. If nothing
5
+ is found, the results of the lookup are the results of qualified name
6
+ lookup in each namespace nominated by a *using-directive* that precedes
7
+ the point of the lookup and inhabits N or an element of N’s inline
8
+ namespace set.
9
 
10
+ [*Note 1*: If a *using-directive* refers to a namespace that has
11
+ already been considered, it does not affect the result. *end note*]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  [*Example 1*:
14
 
15
  ``` cpp
16
  int x;
 
64
  }
65
  ```
66
 
67
  — *end example*]
68
 
69
+ [*Note 2*:
70
 
71
  The same declaration found more than once is not an ambiguity (because
72
  it is still a unique declaration).
73
 
74
  [*Example 2*:
 
91
  using namespace C;
92
  }
93
 
94
  void f()
95
  {
96
+ BC::a++; // OK, S is { `A::a`, `A::a` }
97
  }
98
 
99
  namespace D {
100
  using A::a;
101
  }
 
105
  using namespace D;
106
  }
107
 
108
  void g()
109
  {
110
+ BD::a++; // OK, S is { `A::a`, `A::a` }
111
  }
112
  ```
113
 
114
  — *end example*]
115
 
 
134
  using namespace A;
135
  }
136
 
137
  void f()
138
  {
139
+ A::a++; // OK, a declared directly in A, S is { `A::a` }
140
+ B::a++; // OK, both A and B searched (once), S is { `A::a` }
141
+ A::b++; // OK, both A and B searched (once), S is { `B::b` }
142
+ B::b++; // OK, b declared directly in B, S is { `B::b` }
143
  }
144
  ```
145
 
146
  — *end example*]
147
 
148
+ [*Note 3*: Class and enumeration declarations are not discarded because
149
+ of other declarations found in other searches. *end note*]
 
 
 
 
 
150
 
151
  [*Example 4*:
152
 
153
  ``` cpp
154
  namespace A {
 
169
  }
170
  ```
171
 
172
  — *end example*]
173