tmp/tmpj9v8da2b/{from.md → to.md}
RENAMED
|
@@ -146,18 +146,37 @@ void f() {
|
|
| 146 |
— *end example*]
|
| 147 |
|
| 148 |
If a declaration is named by two *using-declarator*s that inhabit the
|
| 149 |
same class scope, the program is ill-formed.
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
[*Note 3*: A *using-declarator* whose *nested-name-specifier* names a
|
| 152 |
namespace does not name declarations added to the namespace after it.
|
| 153 |
Thus, additional overloads added after the *using-declaration* are
|
| 154 |
ignored, but default function arguments [[dcl.fct.default]], default
|
| 155 |
template arguments [[temp.param]], and template specializations
|
| 156 |
[[temp.spec.partial]], [[temp.expl.spec]] are considered. — *end note*]
|
| 157 |
|
| 158 |
-
[*Example
|
| 159 |
|
| 160 |
``` cpp
|
| 161 |
namespace A {
|
| 162 |
void f(int);
|
| 163 |
}
|
|
@@ -178,21 +197,37 @@ void bar() {
|
|
| 178 |
```
|
| 179 |
|
| 180 |
— *end example*]
|
| 181 |
|
| 182 |
If a declaration named by a *using-declaration* that inhabits the target
|
| 183 |
-
scope of another declaration potentially conflicts with it
|
| 184 |
[[basic.scope.scope]], and either is reachable from the other, the
|
| 185 |
-
program is ill-formed
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
[*Note 4*: Overload resolution possibly cannot distinguish between
|
| 191 |
conflicting function declarations. — *end note*]
|
| 192 |
|
| 193 |
-
[*Example
|
| 194 |
|
| 195 |
``` cpp
|
| 196 |
namespace A {
|
| 197 |
int x;
|
| 198 |
int f(int);
|
|
@@ -224,10 +259,11 @@ void func() {
|
|
| 224 |
using A::g; // error: conflicts with B::g
|
| 225 |
void h();
|
| 226 |
using A::h; // error: conflicts
|
| 227 |
using B::x;
|
| 228 |
using A::x; // OK, hides struct B::x
|
|
|
|
| 229 |
x = 99; // assigns to A::x
|
| 230 |
struct x x1; // x1 has class type B::x
|
| 231 |
}
|
| 232 |
```
|
| 233 |
|
|
@@ -236,11 +272,11 @@ void func() {
|
|
| 236 |
The set of declarations named by a *using-declarator* that inhabits a
|
| 237 |
class `C` does not include member functions and member function
|
| 238 |
templates of a base class that correspond to (and thus would conflict
|
| 239 |
with) a declaration of a function or function template in `C`.
|
| 240 |
|
| 241 |
-
[*Example
|
| 242 |
|
| 243 |
``` cpp
|
| 244 |
struct B {
|
| 245 |
virtual void f(int);
|
| 246 |
virtual void f(char);
|
|
@@ -322,11 +358,11 @@ names a constructor, no access check is performed.
|
|
| 322 |
Because a *using-declarator* designates a base class member (and not a
|
| 323 |
member subobject or a member function of a base class subobject), a
|
| 324 |
*using-declarator* cannot be used to resolve inherited member
|
| 325 |
ambiguities.
|
| 326 |
|
| 327 |
-
[*Example
|
| 328 |
|
| 329 |
``` cpp
|
| 330 |
struct A { int x(); };
|
| 331 |
struct B : A { };
|
| 332 |
struct C : A {
|
|
@@ -351,11 +387,11 @@ A *using-declaration* has the usual accessibility for a
|
|
| 351 |
*member-declaration*. Base-class constructors considered because of a
|
| 352 |
*using-declarator* are accessible if they would be accessible when used
|
| 353 |
to construct an object of the base class; the accessibility of the
|
| 354 |
*using-declaration* is ignored.
|
| 355 |
|
| 356 |
-
[*Example
|
| 357 |
|
| 358 |
``` cpp
|
| 359 |
class A {
|
| 360 |
private:
|
| 361 |
void f(char);
|
|
|
|
| 146 |
— *end example*]
|
| 147 |
|
| 148 |
If a declaration is named by two *using-declarator*s that inhabit the
|
| 149 |
same class scope, the program is ill-formed.
|
| 150 |
|
| 151 |
+
[*Example 5*:
|
| 152 |
+
|
| 153 |
+
``` cpp
|
| 154 |
+
struct C {
|
| 155 |
+
int i;
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
struct D1 : C { };
|
| 159 |
+
struct D2 : C { };
|
| 160 |
+
|
| 161 |
+
struct D3 : D1, D2 {
|
| 162 |
+
using D1::i; // OK, equivalent to using C::i
|
| 163 |
+
using D1::i; // error: duplicate
|
| 164 |
+
using D2::i; // error: duplicate, also names C::i
|
| 165 |
+
};
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
— *end example*]
|
| 169 |
+
|
| 170 |
[*Note 3*: A *using-declarator* whose *nested-name-specifier* names a
|
| 171 |
namespace does not name declarations added to the namespace after it.
|
| 172 |
Thus, additional overloads added after the *using-declaration* are
|
| 173 |
ignored, but default function arguments [[dcl.fct.default]], default
|
| 174 |
template arguments [[temp.param]], and template specializations
|
| 175 |
[[temp.spec.partial]], [[temp.expl.spec]] are considered. — *end note*]
|
| 176 |
|
| 177 |
+
[*Example 6*:
|
| 178 |
|
| 179 |
``` cpp
|
| 180 |
namespace A {
|
| 181 |
void f(int);
|
| 182 |
}
|
|
|
|
| 197 |
```
|
| 198 |
|
| 199 |
— *end example*]
|
| 200 |
|
| 201 |
If a declaration named by a *using-declaration* that inhabits the target
|
| 202 |
+
scope of another declaration B potentially conflicts with it
|
| 203 |
[[basic.scope.scope]], and either is reachable from the other, the
|
| 204 |
+
program is ill-formed unless B is name-independent and the
|
| 205 |
+
*using-declaration* precedes B.
|
| 206 |
+
|
| 207 |
+
[*Example 7*:
|
| 208 |
+
|
| 209 |
+
``` cpp
|
| 210 |
+
int _;
|
| 211 |
+
void f() {
|
| 212 |
+
int _; // B
|
| 213 |
+
_ = 0;
|
| 214 |
+
using ::_; // error: using-declaration does not precede B
|
| 215 |
+
}
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
— *end example*]
|
| 219 |
+
|
| 220 |
+
If two declarations named by *using-declaration*s that inhabit the same
|
| 221 |
+
scope potentially conflict, either is reachable from the other, and they
|
| 222 |
+
do not both declare functions or function templates, the program is
|
| 223 |
+
ill-formed.
|
| 224 |
|
| 225 |
[*Note 4*: Overload resolution possibly cannot distinguish between
|
| 226 |
conflicting function declarations. — *end note*]
|
| 227 |
|
| 228 |
+
[*Example 8*:
|
| 229 |
|
| 230 |
``` cpp
|
| 231 |
namespace A {
|
| 232 |
int x;
|
| 233 |
int f(int);
|
|
|
|
| 259 |
using A::g; // error: conflicts with B::g
|
| 260 |
void h();
|
| 261 |
using A::h; // error: conflicts
|
| 262 |
using B::x;
|
| 263 |
using A::x; // OK, hides struct B::x
|
| 264 |
+
using A::x; // OK, does not conflict with previous using A::x
|
| 265 |
x = 99; // assigns to A::x
|
| 266 |
struct x x1; // x1 has class type B::x
|
| 267 |
}
|
| 268 |
```
|
| 269 |
|
|
|
|
| 272 |
The set of declarations named by a *using-declarator* that inhabits a
|
| 273 |
class `C` does not include member functions and member function
|
| 274 |
templates of a base class that correspond to (and thus would conflict
|
| 275 |
with) a declaration of a function or function template in `C`.
|
| 276 |
|
| 277 |
+
[*Example 9*:
|
| 278 |
|
| 279 |
``` cpp
|
| 280 |
struct B {
|
| 281 |
virtual void f(int);
|
| 282 |
virtual void f(char);
|
|
|
|
| 358 |
Because a *using-declarator* designates a base class member (and not a
|
| 359 |
member subobject or a member function of a base class subobject), a
|
| 360 |
*using-declarator* cannot be used to resolve inherited member
|
| 361 |
ambiguities.
|
| 362 |
|
| 363 |
+
[*Example 10*:
|
| 364 |
|
| 365 |
``` cpp
|
| 366 |
struct A { int x(); };
|
| 367 |
struct B : A { };
|
| 368 |
struct C : A {
|
|
|
|
| 387 |
*member-declaration*. Base-class constructors considered because of a
|
| 388 |
*using-declarator* are accessible if they would be accessible when used
|
| 389 |
to construct an object of the base class; the accessibility of the
|
| 390 |
*using-declaration* is ignored.
|
| 391 |
|
| 392 |
+
[*Example 11*:
|
| 393 |
|
| 394 |
``` cpp
|
| 395 |
class A {
|
| 396 |
private:
|
| 397 |
void f(char);
|