From Jason Turner

[namespace.udir]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp17cl5uu_/{from.md → to.md} +29 -41
tmp/tmp17cl5uu_/{from.md → to.md} RENAMED
@@ -13,22 +13,19 @@ only namespace names are considered, see 
13
  [[basic.lookup.udir]]. — *end note*]
14
 
15
  The optional *attribute-specifier-seq* appertains to the
16
  *using-directive*.
17
 
18
- A *using-directive* specifies that the names in the nominated namespace
19
- can be used in the scope in which the *using-directive* appears after
20
- the *using-directive*. During unqualified name lookup
21
- [[basic.lookup.unqual]], the names appear as if they were declared in
22
- the nearest enclosing namespace which contains both the
23
- *using-directive* and the nominated namespace.
24
 
25
- [*Note 2*: In this context, “contains” means “contains directly or
26
- indirectly”. — *end note*]
27
-
28
- A *using-directive* does not add any members to the declarative region
29
- in which it appears.
30
 
31
  [*Example 1*:
32
 
33
  ``` cpp
34
  namespace A {
@@ -58,18 +55,14 @@ void f4() {
58
  }
59
  ```
60
 
61
  — *end example*]
62
 
63
- For unqualified lookup [[basic.lookup.unqual]], the *using-directive* is
64
- transitive: if a scope contains a *using-directive* that nominates a
65
- second namespace that itself contains *using-directive*s, the effect is
66
- as if the *using-directive*s from the second namespace also appeared in
67
- the first.
68
-
69
- [*Note 3*: For qualified lookup, see 
70
- [[namespace.qual]]. — *end note*]
71
 
72
  [*Example 2*:
73
 
74
  ``` cpp
75
  namespace M {
@@ -112,17 +105,15 @@ namespace B {
112
  }
113
  ```
114
 
115
  — *end example*]
116
 
117
- If a namespace is extended [[namespace.def]] after a *using-directive*
118
- for that namespace is given, the additional members of the extended
119
- namespace and the members of namespaces nominated by *using-directive*s
120
- in the extending *namespace-definition* can be used after the extending
121
- *namespace-definition*.
122
 
123
- [*Note 4*:
124
 
125
  If name lookup finds a declaration for a name in two different
126
  namespaces, and the declarations do not declare the same entity and do
127
  not declare functions or function templates, the use of the name is
128
  ill-formed [[basic.lookup]]. In particular, the name of a variable,
@@ -143,40 +134,37 @@ namespace B {
143
  using namespace A;
144
  using namespace B;
145
 
146
  void f() {
147
  X(1); // error: name X found in two namespaces
148
- g(); // OK: name g refers to the same entity
149
- h(); // OK: overload resolution selects A::h
150
  }
151
  ```
152
 
153
  — *end note*]
154
 
155
- During overload resolution, all functions from the transitive search are
156
- considered for argument matching. The set of declarations found by the
157
- transitive search is unordered.
158
 
159
- [*Note 5*: In particular, the order in which namespaces were considered
160
- and the relationships among the namespaces implied by the
161
- *using-directive*s do not cause preference to be given to any of the
162
- declarations found by the search. *end note*]
 
163
 
164
- An ambiguity exists if the best match finds two functions with the same
165
- signature, even if one is in a namespace reachable through
166
- *using-directive*s in the namespace of the other.[^11]
167
 
168
  [*Example 3*:
169
 
170
  ``` cpp
171
  namespace D {
172
  int d1;
173
  void f(char);
174
  }
175
  using namespace D;
176
 
177
- int d1; // OK: no conflict with D::d1
178
 
179
  namespace E {
180
  int e;
181
  void f(int);
182
  }
@@ -189,14 +177,14 @@ namespace D { // namespace extension
189
 
190
  void f() {
191
  d1++; // error: ambiguous ::d1 or D::d1?
192
  ::d1++; // OK
193
  D::d1++; // OK
194
- d2++; // OK: D::d2
195
- e++; // OK: E::e
196
  f(1); // error: ambiguous: D::f(int) or E::f(int)?
197
- f('a'); // OK: D::f(char)
198
  }
199
  ```
200
 
201
  — *end example*]
202
 
 
13
  [[basic.lookup.udir]]. — *end note*]
14
 
15
  The optional *attribute-specifier-seq* appertains to the
16
  *using-directive*.
17
 
18
+ [*Note 2*: A *using-directive* makes the names in the nominated
19
+ namespace usable in the scope in which the *using-directive* appears
20
+ after the *using-directive* [[basic.lookup.unqual]], [[namespace.qual]].
21
+ During unqualified name lookup, the names appear as if they were
22
+ declared in the nearest enclosing namespace which contains both the
23
+ *using-directive* and the nominated namespace. — *end note*]
24
 
25
+ [*Note 3*: A *using-directive* does not introduce any
26
+ names. — *end note*]
 
 
 
27
 
28
  [*Example 1*:
29
 
30
  ``` cpp
31
  namespace A {
 
55
  }
56
  ```
57
 
58
  — *end example*]
59
 
60
+ [*Note 4*: A *using-directive* is transitive: if a scope contains a
61
+ *using-directive* that nominates a namespace that itself contains
62
+ *using-directive*s, the namespaces nominated by those *using-directive*s
63
+ are also eligible to be considered. *end note*]
 
 
 
 
64
 
65
  [*Example 2*:
66
 
67
  ``` cpp
68
  namespace M {
 
105
  }
106
  ```
107
 
108
  — *end example*]
109
 
110
+ [*Note 5*: Declarations in a namespace that appear after a
111
+ *using-directive* for that namespace can be found through that
112
+ *using-directive* after they appear. *end note*]
 
 
113
 
114
+ [*Note 6*:
115
 
116
  If name lookup finds a declaration for a name in two different
117
  namespaces, and the declarations do not declare the same entity and do
118
  not declare functions or function templates, the use of the name is
119
  ill-formed [[basic.lookup]]. In particular, the name of a variable,
 
134
  using namespace A;
135
  using namespace B;
136
 
137
  void f() {
138
  X(1); // error: name X found in two namespaces
139
+ g(); // OK, name g refers to the same entity
140
+ h(); // OK, overload resolution selects A::h
141
  }
142
  ```
143
 
144
  — *end note*]
145
 
146
+ [*Note 7*:
 
 
147
 
148
+ The order in which namespaces are considered and the relationships among
149
+ the namespaces implied by the *using-directive*s do not affect overload
150
+ resolution. Neither is any function excluded because another has the
151
+ same signature, even if one is in a namespace reachable through
152
+ *using-directive*s in the namespace of the other.[^10]
153
 
154
+ *end note*]
 
 
155
 
156
  [*Example 3*:
157
 
158
  ``` cpp
159
  namespace D {
160
  int d1;
161
  void f(char);
162
  }
163
  using namespace D;
164
 
165
+ int d1; // OK, no conflict with D::d1
166
 
167
  namespace E {
168
  int e;
169
  void f(int);
170
  }
 
177
 
178
  void f() {
179
  d1++; // error: ambiguous ::d1 or D::d1?
180
  ::d1++; // OK
181
  D::d1++; // OK
182
+ d2++; // OK, D::d2
183
+ e++; // OK, E::e
184
  f(1); // error: ambiguous: D::f(int) or E::f(int)?
185
+ f('a'); // OK, D::f(char)
186
  }
187
  ```
188
 
189
  — *end example*]
190