From Jason Turner

[basic.namespace]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6ozy9p9n/{from.md → to.md} +67 -235
tmp/tmp6ozy9p9n/{from.md → to.md} RENAMED
@@ -1,18 +1,20 @@
1
  ## Namespaces <a id="basic.namespace">[[basic.namespace]]</a>
2
 
3
- A namespace is an optionally-named declarative region. The name of a
4
- namespace can be used to access entities declared in that namespace;
5
- that is, the members of the namespace. Unlike other declarative regions,
6
- the definition of a namespace can be split over several parts of one or
7
- more translation units.
8
 
9
- [*Note 1*: A namespace name with external linkage is exported if any of
10
- its *namespace-definition*s is exported, or if it contains any
 
 
 
 
 
 
11
  *export-declaration*s [[module.interface]]. A namespace is never
12
- attached to a module, and never has module linkage even if it is not
13
- exported. — *end note*]
14
 
15
  [*Example 1*:
16
 
17
  ``` cpp
18
  export module M;
@@ -21,15 +23,21 @@ export namespace N2 {} // N2 is exported
21
  namespace N3 { export int n; } // N3 is exported
22
  ```
23
 
24
  — *end example*]
25
 
26
- The outermost declarative region of a translation unit is a namespace;
27
- see  [[basic.scope.namespace]].
 
 
 
 
28
 
29
  ### Namespace definition <a id="namespace.def">[[namespace.def]]</a>
30
 
 
 
31
  ``` bnf
32
  namespace-name:
33
  identifier
34
  namespace-alias
35
  ```
@@ -65,22 +73,20 @@ enclosing-namespace-specifier:
65
  ``` bnf
66
  namespace-body:
67
  declaration-seqₒₚₜ
68
  ```
69
 
70
- Every *namespace-definition* shall appear at namespace scope
71
  [[basic.scope.namespace]].
72
 
73
- In a *named-namespace-definition*, the *identifier* is the name of the
74
- namespace. If the *identifier*, when looked up [[basic.lookup.unqual]],
75
- refers to a *namespace-name* (but not a *namespace-alias*) that was
76
- introduced in the namespace in which the *named-namespace-definition*
77
- appears or that was introduced in a member of the inline namespace set
78
- of that namespace, the *namespace-definition* *extends* the
79
- previously-declared namespace. Otherwise, the *identifier* is introduced
80
- as a *namespace-name* into the declarative region in which the
81
- *named-namespace-definition* appears.
82
 
83
  Because a *namespace-definition* contains *declaration*s in its
84
  *namespace-body* and a *namespace-definition* is itself a *declaration*,
85
  it follows that *namespace-definition*s can be nested.
86
 
@@ -97,34 +103,10 @@ namespace Outer {
97
  }
98
  ```
99
 
100
  — *end example*]
101
 
102
- The *enclosing namespaces* of a declaration are those namespaces in
103
- which the declaration lexically appears, except for a redeclaration of a
104
- namespace member outside its original namespace (e.g., a definition as
105
- specified in  [[namespace.memdef]]). Such a redeclaration has the same
106
- enclosing namespaces as the original declaration.
107
-
108
- [*Example 2*:
109
-
110
- ``` cpp
111
- namespace Q {
112
- namespace V {
113
- void f(); // enclosing namespaces are the global namespace, Q, and Q::V
114
- class C { void m(); };
115
- }
116
- void V::f() { // enclosing namespaces are the global namespace, Q, and Q::V
117
- extern void h(); // ... so this declares Q::V::h
118
- }
119
- void V::C::m() { // enclosing namespaces are the global namespace, Q, and Q::V
120
- }
121
- }
122
- ```
123
-
124
- — *end example*]
125
-
126
  If the optional initial `inline` keyword appears in a
127
  *namespace-definition* for a particular namespace, that namespace is
128
  declared to be an *inline namespace*. The `inline` keyword may be used
129
  on a *namespace-definition* that extends a namespace only if it was
130
  previously used on the *namespace-definition* that initially declared
@@ -132,33 +114,30 @@ the *namespace-name* for that namespace.
132
 
133
  The optional *attribute-specifier-seq* in a *named-namespace-definition*
134
  appertains to the namespace being defined or extended.
135
 
136
  Members of an inline namespace can be used in most respects as though
137
- they were members of the enclosing namespace. Specifically, the inline
138
- namespace and its enclosing namespace are both added to the set of
139
- associated namespaces used in argument-dependent lookup
140
  [[basic.lookup.argdep]] whenever one of them is, and a *using-directive*
141
  [[namespace.udir]] that names the inline namespace is implicitly
142
  inserted into the enclosing namespace as for an unnamed namespace
143
  [[namespace.unnamed]]. Furthermore, each member of the inline namespace
144
- can subsequently be partially specialized [[temp.class.spec]],
145
  explicitly instantiated [[temp.explicit]], or explicitly specialized
146
  [[temp.expl.spec]] as though it were a member of the enclosing
147
  namespace. Finally, looking up a name in the enclosing namespace via
148
  explicit qualification [[namespace.qual]] will include members of the
149
- inline namespace brought in by the *using-directive* even if there are
150
- declarations of that name in the enclosing namespace.
151
 
152
  These properties are transitive: if a namespace `N` contains an inline
153
  namespace `M`, which in turn contains an inline namespace `O`, then the
154
  members of `O` can be used as though they were members of `M` or `N`.
155
  The *inline namespace set* of `N` is the transitive closure of all
156
- inline namespaces in `N`. The *enclosing namespace set* of `O` is the
157
- set of namespaces consisting of the innermost non-inline namespace
158
- enclosing an inline namespace `O`, together with any intervening inline
159
- namespaces.
160
 
161
  A *nested-namespace-definition* with an *enclosing-namespace-specifier*
162
  `E`, *identifier* `I` and *namespace-body* `B` is equivalent to
163
 
164
  ``` cpp
@@ -166,11 +145,11 @@ namespace E { \opt{inline} namespace I { B } }
166
  ```
167
 
168
  where the optional `inline` is present if and only if the *identifier*
169
  `I` is preceded by `inline`.
170
 
171
- [*Example 3*:
172
 
173
  ``` cpp
174
  namespace A::inline B::C {
175
  int i;
176
  }
@@ -229,128 +208,10 @@ void h() {
229
  }
230
  ```
231
 
232
  — *end example*]
233
 
234
- #### Namespace member definitions <a id="namespace.memdef">[[namespace.memdef]]</a>
235
-
236
- A declaration in a namespace `N` (excluding declarations in nested
237
- scopes) whose *declarator-id* is an *unqualified-id* [[dcl.meaning]],
238
- whose *class-head-name* [[class.pre]] or *enum-head-name* [[dcl.enum]]
239
- is an *identifier*, or whose *elaborated-type-specifier* is of the form
240
- *class-key* *attribute-specifier-seq*ₒₚₜ *identifier*
241
- [[dcl.type.elab]], or that is an *opaque-enum-declaration*, declares (or
242
- redeclares) its *unqualified-id* or *identifier* as a member of `N`.
243
-
244
- [*Note 1*: An explicit instantiation [[temp.explicit]] or explicit
245
- specialization [[temp.expl.spec]] of a template does not introduce a
246
- name and thus may be declared using an *unqualified-id* in a member of
247
- the enclosing namespace set, if the primary template is declared in an
248
- inline namespace. — *end note*]
249
-
250
- [*Example 1*:
251
-
252
- ``` cpp
253
- namespace X {
254
- void f() { ... } // OK: introduces X::f()
255
-
256
- namespace M {
257
- void g(); // OK: introduces X::M::g()
258
- }
259
- using M::g;
260
- void g(); // error: conflicts with X::M::g()
261
- }
262
- ```
263
-
264
- — *end example*]
265
-
266
- Members of a named namespace can also be defined outside that namespace
267
- by explicit qualification [[namespace.qual]] of the name being defined,
268
- provided that the entity being defined was already declared in the
269
- namespace and the definition appears after the point of declaration in a
270
- namespace that encloses the declaration’s namespace.
271
-
272
- [*Example 2*:
273
-
274
- ``` cpp
275
- namespace Q {
276
- namespace V {
277
- void f();
278
- }
279
- void V::f() { ... } // OK
280
- void V::g() { ... } // error: g() is not yet a member of V
281
- namespace V {
282
- void g();
283
- }
284
- }
285
-
286
- namespace R {
287
- void Q::V::g() { ... } // error: R doesn't enclose Q
288
- }
289
- ```
290
-
291
- — *end example*]
292
-
293
- If a friend declaration in a non-local class first declares a class,
294
- function, class template or function template[^10] the friend is a
295
- member of the innermost enclosing namespace. The friend declaration does
296
- not by itself make the name visible to unqualified lookup
297
- [[basic.lookup.unqual]] or qualified lookup [[basic.lookup.qual]].
298
-
299
- [*Note 2*: The name of the friend will be visible in its namespace if a
300
- matching declaration is provided at namespace scope (either before or
301
- after the class definition granting friendship). — *end note*]
302
-
303
- If a friend function or function template is called, its name may be
304
- found by the name lookup that considers functions from namespaces and
305
- classes associated with the types of the function arguments
306
- [[basic.lookup.argdep]]. If the name in a friend declaration is neither
307
- qualified nor a *template-id* and the declaration is a function or an
308
- *elaborated-type-specifier*, the lookup to determine whether the entity
309
- has been previously declared shall not consider any scopes outside the
310
- innermost enclosing namespace.
311
-
312
- [*Note 3*: The other forms of friend declarations cannot declare a new
313
- member of the innermost enclosing namespace and thus follow the usual
314
- lookup rules. — *end note*]
315
-
316
- [*Example 3*:
317
-
318
- ``` cpp
319
- // Assume f and g have not yet been declared.
320
- void h(int);
321
- template <class T> void f2(T);
322
- namespace A {
323
- class X {
324
- friend void f(X); // A::f(X) is a friend
325
- class Y {
326
- friend void g(); // A::g is a friend
327
- friend void h(int); // A::h is a friend
328
- // ::h not considered
329
- friend void f2<>(int); // ::f2<>(int) is a friend
330
- };
331
- };
332
-
333
- // A::f, A::g and A::h are not visible here
334
- X x;
335
- void g() { f(x); } // definition of A::g
336
- void f(X) { ... } // definition of A::f
337
- void h(int) { ... } // definition of A::h
338
- // A::f, A::g and A::h are visible here and known to be friends
339
- }
340
-
341
- using A::x;
342
-
343
- void h() {
344
- A::f(x);
345
- A::X::f(x); // error: f is not a member of A::X
346
- A::X::Y::g(); // error: g is not a member of A::X::Y
347
- }
348
- ```
349
-
350
- — *end example*]
351
-
352
  ### Namespace alias <a id="namespace.alias">[[namespace.alias]]</a>
353
 
354
  A *namespace-alias-definition* declares an alternate name for a
355
  namespace according to the following grammar:
356
 
@@ -367,35 +228,18 @@ namespace-alias-definition:
367
  ``` bnf
368
  qualified-namespace-specifier:
369
  nested-name-specifierₒₚₜ namespace-name
370
  ```
371
 
372
- The *identifier* in a *namespace-alias-definition* is a synonym for the
373
- name of the namespace denoted by the *qualified-namespace-specifier* and
374
- becomes a *namespace-alias*.
375
 
376
  [*Note 1*: When looking up a *namespace-name* in a
377
  *namespace-alias-definition*, only namespace names are considered, see 
378
  [[basic.lookup.udir]]. — *end note*]
379
 
380
- In a declarative region, a *namespace-alias-definition* can be used to
381
- redefine a *namespace-alias* declared in that declarative region to
382
- refer only to the namespace to which it already refers.
383
-
384
- [*Example 1*:
385
-
386
- The following declarations are well-formed:
387
-
388
- ``` cpp
389
- namespace Company_with_very_long_name { ... }
390
- namespace CWVLN = Company_with_very_long_name;
391
- namespace CWVLN = Company_with_very_long_name; // OK: duplicate
392
- namespace CWVLN = CWVLN;
393
- ```
394
-
395
- — *end example*]
396
-
397
  ### Using namespace directive <a id="namespace.udir">[[namespace.udir]]</a>
398
 
399
  ``` bnf
400
  using-directive:
401
  attribute-specifier-seqₒₚₜ using namespace nested-name-specifierₒₚₜ namespace-name ';'
@@ -409,22 +253,19 @@ only namespace names are considered, see 
409
  [[basic.lookup.udir]]. — *end note*]
410
 
411
  The optional *attribute-specifier-seq* appertains to the
412
  *using-directive*.
413
 
414
- A *using-directive* specifies that the names in the nominated namespace
415
- can be used in the scope in which the *using-directive* appears after
416
- the *using-directive*. During unqualified name lookup
417
- [[basic.lookup.unqual]], the names appear as if they were declared in
418
- the nearest enclosing namespace which contains both the
419
- *using-directive* and the nominated namespace.
420
 
421
- [*Note 2*: In this context, “contains” means “contains directly or
422
- indirectly”. — *end note*]
423
-
424
- A *using-directive* does not add any members to the declarative region
425
- in which it appears.
426
 
427
  [*Example 1*:
428
 
429
  ``` cpp
430
  namespace A {
@@ -454,18 +295,14 @@ void f4() {
454
  }
455
  ```
456
 
457
  — *end example*]
458
 
459
- For unqualified lookup [[basic.lookup.unqual]], the *using-directive* is
460
- transitive: if a scope contains a *using-directive* that nominates a
461
- second namespace that itself contains *using-directive*s, the effect is
462
- as if the *using-directive*s from the second namespace also appeared in
463
- the first.
464
-
465
- [*Note 3*: For qualified lookup, see 
466
- [[namespace.qual]]. — *end note*]
467
 
468
  [*Example 2*:
469
 
470
  ``` cpp
471
  namespace M {
@@ -508,17 +345,15 @@ namespace B {
508
  }
509
  ```
510
 
511
  — *end example*]
512
 
513
- If a namespace is extended [[namespace.def]] after a *using-directive*
514
- for that namespace is given, the additional members of the extended
515
- namespace and the members of namespaces nominated by *using-directive*s
516
- in the extending *namespace-definition* can be used after the extending
517
- *namespace-definition*.
518
 
519
- [*Note 4*:
520
 
521
  If name lookup finds a declaration for a name in two different
522
  namespaces, and the declarations do not declare the same entity and do
523
  not declare functions or function templates, the use of the name is
524
  ill-formed [[basic.lookup]]. In particular, the name of a variable,
@@ -539,40 +374,37 @@ namespace B {
539
  using namespace A;
540
  using namespace B;
541
 
542
  void f() {
543
  X(1); // error: name X found in two namespaces
544
- g(); // OK: name g refers to the same entity
545
- h(); // OK: overload resolution selects A::h
546
  }
547
  ```
548
 
549
  — *end note*]
550
 
551
- During overload resolution, all functions from the transitive search are
552
- considered for argument matching. The set of declarations found by the
553
- transitive search is unordered.
554
 
555
- [*Note 5*: In particular, the order in which namespaces were considered
556
- and the relationships among the namespaces implied by the
557
- *using-directive*s do not cause preference to be given to any of the
558
- declarations found by the search. *end note*]
 
559
 
560
- An ambiguity exists if the best match finds two functions with the same
561
- signature, even if one is in a namespace reachable through
562
- *using-directive*s in the namespace of the other.[^11]
563
 
564
  [*Example 3*:
565
 
566
  ``` cpp
567
  namespace D {
568
  int d1;
569
  void f(char);
570
  }
571
  using namespace D;
572
 
573
- int d1; // OK: no conflict with D::d1
574
 
575
  namespace E {
576
  int e;
577
  void f(int);
578
  }
@@ -585,14 +417,14 @@ namespace D { // namespace extension
585
 
586
  void f() {
587
  d1++; // error: ambiguous ::d1 or D::d1?
588
  ::d1++; // OK
589
  D::d1++; // OK
590
- d2++; // OK: D::d2
591
- e++; // OK: E::e
592
  f(1); // error: ambiguous: D::f(int) or E::f(int)?
593
- f('a'); // OK: D::f(char)
594
  }
595
  ```
596
 
597
  — *end example*]
598
 
 
1
  ## Namespaces <a id="basic.namespace">[[basic.namespace]]</a>
2
 
3
+ ### General <a id="basic.namespace.general">[[basic.namespace.general]]</a>
 
 
 
 
4
 
5
+ A namespace is an optionally-named entity whose scope can contain
6
+ declarations of any kind of entity. The name of a namespace can be used
7
+ to access entities that belong to that namespace; that is, the *members*
8
+ of the namespace. Unlike other entities, the definition of a namespace
9
+ can be split over several parts of one or more translation units and
10
+ modules.
11
+
12
+ [*Note 1*: A *namespace-definition* is exported if it contains any
13
  *export-declaration*s [[module.interface]]. A namespace is never
14
+ attached to a named module and never has a name with module
15
+ linkage. — *end note*]
16
 
17
  [*Example 1*:
18
 
19
  ``` cpp
20
  export module M;
 
23
  namespace N3 { export int n; } // N3 is exported
24
  ```
25
 
26
  — *end example*]
27
 
28
+ There is a *global namespace* with no declaration; see 
29
+ [[basic.scope.namespace]]. The global namespace belongs to the global
30
+ scope; it is not an unnamed namespace [[namespace.unnamed]].
31
+
32
+ [*Note 2*: Lacking a declaration, it cannot be found by name
33
+ lookup. — *end note*]
34
 
35
  ### Namespace definition <a id="namespace.def">[[namespace.def]]</a>
36
 
37
+ #### General <a id="namespace.def.general">[[namespace.def.general]]</a>
38
+
39
  ``` bnf
40
  namespace-name:
41
  identifier
42
  namespace-alias
43
  ```
 
73
  ``` bnf
74
  namespace-body:
75
  declaration-seqₒₚₜ
76
  ```
77
 
78
+ Every *namespace-definition* shall inhabit a namespace scope
79
  [[basic.scope.namespace]].
80
 
81
+ In a *named-namespace-definition* D, the *identifier* is the name of the
82
+ namespace. The *identifier* is looked up by searching for it in the
83
+ scopes of the namespace A in which D appears and of every element of the
84
+ inline namespace set of A. If the lookup finds a *namespace-definition*
85
+ for a namespace N, D *extends* N, and the target scope of D is the scope
86
+ to which N belongs. If the lookup finds nothing, the *identifier* is
87
+ introduced as a *namespace-name* into A.
 
 
88
 
89
  Because a *namespace-definition* contains *declaration*s in its
90
  *namespace-body* and a *namespace-definition* is itself a *declaration*,
91
  it follows that *namespace-definition*s can be nested.
92
 
 
103
  }
104
  ```
105
 
106
  — *end example*]
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  If the optional initial `inline` keyword appears in a
109
  *namespace-definition* for a particular namespace, that namespace is
110
  declared to be an *inline namespace*. The `inline` keyword may be used
111
  on a *namespace-definition* that extends a namespace only if it was
112
  previously used on the *namespace-definition* that initially declared
 
114
 
115
  The optional *attribute-specifier-seq* in a *named-namespace-definition*
116
  appertains to the namespace being defined or extended.
117
 
118
  Members of an inline namespace can be used in most respects as though
119
+ they were members of the innermost enclosing namespace. Specifically,
120
+ the inline namespace and its enclosing namespace are both added to the
121
+ set of associated namespaces used in argument-dependent lookup
122
  [[basic.lookup.argdep]] whenever one of them is, and a *using-directive*
123
  [[namespace.udir]] that names the inline namespace is implicitly
124
  inserted into the enclosing namespace as for an unnamed namespace
125
  [[namespace.unnamed]]. Furthermore, each member of the inline namespace
126
+ can subsequently be partially specialized [[temp.spec.partial]],
127
  explicitly instantiated [[temp.explicit]], or explicitly specialized
128
  [[temp.expl.spec]] as though it were a member of the enclosing
129
  namespace. Finally, looking up a name in the enclosing namespace via
130
  explicit qualification [[namespace.qual]] will include members of the
131
+ inline namespace even if there are declarations of that name in the
132
+ enclosing namespace.
133
 
134
  These properties are transitive: if a namespace `N` contains an inline
135
  namespace `M`, which in turn contains an inline namespace `O`, then the
136
  members of `O` can be used as though they were members of `M` or `N`.
137
  The *inline namespace set* of `N` is the transitive closure of all
138
+ inline namespaces in `N`.
 
 
 
139
 
140
  A *nested-namespace-definition* with an *enclosing-namespace-specifier*
141
  `E`, *identifier* `I` and *namespace-body* `B` is equivalent to
142
 
143
  ``` cpp
 
145
  ```
146
 
147
  where the optional `inline` is present if and only if the *identifier*
148
  `I` is preceded by `inline`.
149
 
150
+ [*Example 2*:
151
 
152
  ``` cpp
153
  namespace A::inline B::C {
154
  int i;
155
  }
 
208
  }
209
  ```
210
 
211
  — *end example*]
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  ### Namespace alias <a id="namespace.alias">[[namespace.alias]]</a>
214
 
215
  A *namespace-alias-definition* declares an alternate name for a
216
  namespace according to the following grammar:
217
 
 
228
  ``` bnf
229
  qualified-namespace-specifier:
230
  nested-name-specifierₒₚₜ namespace-name
231
  ```
232
 
233
+ The *identifier* in a *namespace-alias-definition* becomes a
234
+ *namespace-alias* and denotes the namespace denoted by the
235
+ *qualified-namespace-specifier*.
236
 
237
  [*Note 1*: When looking up a *namespace-name* in a
238
  *namespace-alias-definition*, only namespace names are considered, see 
239
  [[basic.lookup.udir]]. — *end note*]
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  ### Using namespace directive <a id="namespace.udir">[[namespace.udir]]</a>
242
 
243
  ``` bnf
244
  using-directive:
245
  attribute-specifier-seqₒₚₜ using namespace nested-name-specifierₒₚₜ namespace-name ';'
 
253
  [[basic.lookup.udir]]. — *end note*]
254
 
255
  The optional *attribute-specifier-seq* appertains to the
256
  *using-directive*.
257
 
258
+ [*Note 2*: A *using-directive* makes the names in the nominated
259
+ namespace usable in the scope in which the *using-directive* appears
260
+ after the *using-directive* [[basic.lookup.unqual]], [[namespace.qual]].
261
+ During unqualified name lookup, the names appear as if they were
262
+ declared in the nearest enclosing namespace which contains both the
263
+ *using-directive* and the nominated namespace. — *end note*]
264
 
265
+ [*Note 3*: A *using-directive* does not introduce any
266
+ names. — *end note*]
 
 
 
267
 
268
  [*Example 1*:
269
 
270
  ``` cpp
271
  namespace A {
 
295
  }
296
  ```
297
 
298
  — *end example*]
299
 
300
+ [*Note 4*: A *using-directive* is transitive: if a scope contains a
301
+ *using-directive* that nominates a namespace that itself contains
302
+ *using-directive*s, the namespaces nominated by those *using-directive*s
303
+ are also eligible to be considered. *end note*]
 
 
 
 
304
 
305
  [*Example 2*:
306
 
307
  ``` cpp
308
  namespace M {
 
345
  }
346
  ```
347
 
348
  — *end example*]
349
 
350
+ [*Note 5*: Declarations in a namespace that appear after a
351
+ *using-directive* for that namespace can be found through that
352
+ *using-directive* after they appear. *end note*]
 
 
353
 
354
+ [*Note 6*:
355
 
356
  If name lookup finds a declaration for a name in two different
357
  namespaces, and the declarations do not declare the same entity and do
358
  not declare functions or function templates, the use of the name is
359
  ill-formed [[basic.lookup]]. In particular, the name of a variable,
 
374
  using namespace A;
375
  using namespace B;
376
 
377
  void f() {
378
  X(1); // error: name X found in two namespaces
379
+ g(); // OK, name g refers to the same entity
380
+ h(); // OK, overload resolution selects A::h
381
  }
382
  ```
383
 
384
  — *end note*]
385
 
386
+ [*Note 7*:
 
 
387
 
388
+ The order in which namespaces are considered and the relationships among
389
+ the namespaces implied by the *using-directive*s do not affect overload
390
+ resolution. Neither is any function excluded because another has the
391
+ same signature, even if one is in a namespace reachable through
392
+ *using-directive*s in the namespace of the other.[^10]
393
 
394
+ *end note*]
 
 
395
 
396
  [*Example 3*:
397
 
398
  ``` cpp
399
  namespace D {
400
  int d1;
401
  void f(char);
402
  }
403
  using namespace D;
404
 
405
+ int d1; // OK, no conflict with D::d1
406
 
407
  namespace E {
408
  int e;
409
  void f(int);
410
  }
 
417
 
418
  void f() {
419
  d1++; // error: ambiguous ::d1 or D::d1?
420
  ::d1++; // OK
421
  D::d1++; // OK
422
+ d2++; // OK, D::d2
423
+ e++; // OK, E::e
424
  f(1); // error: ambiguous: D::f(int) or E::f(int)?
425
+ f('a'); // OK, D::f(char)
426
  }
427
  ```
428
 
429
  — *end example*]
430