- tmp/tmpocjgw56q/{from.md → to.md} +137 -179
tmp/tmpocjgw56q/{from.md → to.md}
RENAMED
|
@@ -1,16 +1,15 @@
|
|
| 1 |
### Qualified name lookup <a id="basic.lookup.qual">[[basic.lookup.qual]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
the program is ill-formed.
|
| 12 |
|
| 13 |
[*Example 1*:
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
class A {
|
|
@@ -20,70 +19,137 @@ public:
|
|
| 20 |
int main() {
|
| 21 |
int A;
|
| 22 |
A::n = 42; // OK
|
| 23 |
A b; // error: A does not name a type
|
| 24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
```
|
| 26 |
|
| 27 |
— *end example*]
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
[*Example 2*:
|
| 39 |
|
|
|
|
|
|
|
| 40 |
``` cpp
|
| 41 |
-
|
| 42 |
-
class C {
|
| 43 |
-
class X { };
|
| 44 |
-
static const int number = 50;
|
| 45 |
-
static X arr[number];
|
| 46 |
-
};
|
| 47 |
-
X C::arr[number]; // error:
|
| 48 |
-
// equivalent to ::X C::arr[C::number];
|
| 49 |
-
// and not to C::X C::arr[C::number];
|
| 50 |
```
|
| 51 |
|
|
|
|
|
|
|
|
|
|
| 52 |
— *end example*]
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
``` bnf
|
| 68 |
-
nested-name-specifierₒₚₜ type-name '::' '~' type-name
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
the second *type-name* is looked up in the same scope as the first.
|
| 72 |
|
| 73 |
[*Example 3*:
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
``` cpp
|
| 76 |
struct C {
|
| 77 |
typedef int I;
|
| 78 |
};
|
| 79 |
typedef int I1, I2;
|
| 80 |
extern int* p;
|
| 81 |
extern int* q;
|
|
|
|
| 82 |
p->C::I::~I(); // I is looked up in the scope of C
|
| 83 |
-
q->I1::~I2();
|
| 84 |
-
|
| 85 |
struct A {
|
| 86 |
~A();
|
| 87 |
};
|
| 88 |
typedef A AB;
|
| 89 |
int main() {
|
|
@@ -92,55 +158,22 @@ int main() {
|
|
| 92 |
}
|
| 93 |
```
|
| 94 |
|
| 95 |
— *end example*]
|
| 96 |
|
| 97 |
-
[*Note 2*: [[basic.lookup.classref]] describes how name lookup
|
| 98 |
-
proceeds after the `.` and `->` operators. — *end note*]
|
| 99 |
-
|
| 100 |
#### Class members <a id="class.qual">[[class.qual]]</a>
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
scope of the class [[class.member.lookup]], except for the cases listed
|
| 105 |
-
below. The name shall represent one or more members of that class or of
|
| 106 |
-
one of its base classes [[class.derived]].
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
- a *conversion-type-id* of a *conversion-function-id* is looked up in
|
| 115 |
-
the same manner as a *conversion-type-id* in a class member access
|
| 116 |
-
(see [[basic.lookup.classref]]);
|
| 117 |
-
- the names in a *template-argument* of a *template-id* are looked up in
|
| 118 |
-
the context in which the entire *postfix-expression* occurs;
|
| 119 |
-
- the lookup for a name specified in a *using-declaration*
|
| 120 |
-
[[namespace.udecl]] also finds class or enumeration names hidden
|
| 121 |
-
within the same scope [[basic.scope.hiding]].
|
| 122 |
-
|
| 123 |
-
In a lookup in which function names are not ignored[^8] and the
|
| 124 |
-
*nested-name-specifier* nominates a class `C`:
|
| 125 |
-
|
| 126 |
-
- if the name specified after the *nested-name-specifier*, when looked
|
| 127 |
-
up in `C`, is the injected-class-name of `C` [[class.pre]], or
|
| 128 |
-
- in a *using-declarator* of a *using-declaration* [[namespace.udecl]]
|
| 129 |
-
that is a *member-declaration*, if the name specified after the
|
| 130 |
-
*nested-name-specifier* is the same as the *identifier* or the
|
| 131 |
-
*simple-template-id*’s *template-name* in the last component of the
|
| 132 |
-
*nested-name-specifier*,
|
| 133 |
-
|
| 134 |
-
the name is instead considered to name the constructor of class `C`.
|
| 135 |
-
|
| 136 |
-
[*Note 2*: For example, the constructor is not an acceptable lookup
|
| 137 |
-
result in an *elaborated-type-specifier* so the constructor would not be
|
| 138 |
-
used in place of the injected-class-name. — *end note*]
|
| 139 |
-
|
| 140 |
-
Such a constructor name shall be used only in the *declarator-id* of a
|
| 141 |
-
declaration that names a constructor or in a *using-declaration*.
|
| 142 |
|
| 143 |
[*Example 1*:
|
| 144 |
|
| 145 |
``` cpp
|
| 146 |
struct A { A(); };
|
|
@@ -154,39 +187,21 @@ A::A a; // error: A::A is not a type name
|
|
| 154 |
struct A::A a2; // object of type A
|
| 155 |
```
|
| 156 |
|
| 157 |
— *end example*]
|
| 158 |
|
| 159 |
-
A class member name hidden by a name in a nested declarative region or
|
| 160 |
-
by the name of a derived class member can still be found if qualified by
|
| 161 |
-
the name of its class followed by the `::` operator.
|
| 162 |
-
|
| 163 |
#### Namespace members <a id="namespace.qual">[[namespace.qual]]</a>
|
| 164 |
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
declarations of `m` in `X` and the inline namespace set of `X`
|
| 175 |
-
[[namespace.def]] whose potential scope [[basic.scope.namespace]] would
|
| 176 |
-
include the namespace in which `m` is declared at the location of the
|
| 177 |
-
*nested-name-specifier*. If S'(X, m) is not empty, S(X, m) is S'(X, m);
|
| 178 |
-
otherwise, S(X, m) is the union of S(Nᵢ, m) for all namespaces Nᵢ
|
| 179 |
-
nominated by *using-directive*s in `X` and its inline namespace set.
|
| 180 |
-
|
| 181 |
-
Given `X::m` (where `X` is a user-declared namespace), or given `::m`
|
| 182 |
-
(where X is the global namespace), if S(X, m) is the empty set, the
|
| 183 |
-
program is ill-formed. Otherwise, if S(X, m) has exactly one member, or
|
| 184 |
-
if the context of the reference is a *using-declaration*
|
| 185 |
-
[[namespace.udecl]], S(X, m) is the required set of declarations of `m`.
|
| 186 |
-
Otherwise if the use of `m` is not one that allows a unique declaration
|
| 187 |
-
to be chosen from S(X, m), the program is ill-formed.
|
| 188 |
|
| 189 |
[*Example 1*:
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
int x;
|
|
@@ -240,11 +255,11 @@ void h()
|
|
| 240 |
}
|
| 241 |
```
|
| 242 |
|
| 243 |
— *end example*]
|
| 244 |
|
| 245 |
-
[*Note
|
| 246 |
|
| 247 |
The same declaration found more than once is not an ambiguity (because
|
| 248 |
it is still a unique declaration).
|
| 249 |
|
| 250 |
[*Example 2*:
|
|
@@ -267,11 +282,11 @@ namespace BC {
|
|
| 267 |
using namespace C;
|
| 268 |
}
|
| 269 |
|
| 270 |
void f()
|
| 271 |
{
|
| 272 |
-
BC::a++; // OK
|
| 273 |
}
|
| 274 |
|
| 275 |
namespace D {
|
| 276 |
using A::a;
|
| 277 |
}
|
|
@@ -281,11 +296,11 @@ namespace BD {
|
|
| 281 |
using namespace D;
|
| 282 |
}
|
| 283 |
|
| 284 |
void g()
|
| 285 |
{
|
| 286 |
-
BD::a++; // OK
|
| 287 |
}
|
| 288 |
```
|
| 289 |
|
| 290 |
— *end example*]
|
| 291 |
|
|
@@ -310,26 +325,21 @@ namespace B {
|
|
| 310 |
using namespace A;
|
| 311 |
}
|
| 312 |
|
| 313 |
void f()
|
| 314 |
{
|
| 315 |
-
A::a++; // OK
|
| 316 |
-
B::a++; // OK
|
| 317 |
-
A::b++; // OK
|
| 318 |
-
B::b++; // OK
|
| 319 |
}
|
| 320 |
```
|
| 321 |
|
| 322 |
— *end example*]
|
| 323 |
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
introduces a class name or enumeration name and the other declarations
|
| 327 |
-
introduce either the same variable, the same enumerator, or a set of
|
| 328 |
-
functions, the non-type name hides the class or enumeration name if and
|
| 329 |
-
only if the declarations are from the same namespace; otherwise (the
|
| 330 |
-
declarations are from different namespaces), the program is ill-formed.
|
| 331 |
|
| 332 |
[*Example 4*:
|
| 333 |
|
| 334 |
``` cpp
|
| 335 |
namespace A {
|
|
@@ -350,57 +360,5 @@ namespace C {
|
|
| 350 |
}
|
| 351 |
```
|
| 352 |
|
| 353 |
— *end example*]
|
| 354 |
|
| 355 |
-
In a declaration for a namespace member in which the *declarator-id* is
|
| 356 |
-
a *qualified-id*, given that the *qualified-id* for the namespace member
|
| 357 |
-
has the form
|
| 358 |
-
|
| 359 |
-
``` bnf
|
| 360 |
-
nested-name-specifier unqualified-id
|
| 361 |
-
```
|
| 362 |
-
|
| 363 |
-
the *unqualified-id* shall name a member of the namespace designated by
|
| 364 |
-
the *nested-name-specifier* or of an element of the inline namespace set
|
| 365 |
-
[[namespace.def]] of that namespace.
|
| 366 |
-
|
| 367 |
-
[*Example 5*:
|
| 368 |
-
|
| 369 |
-
``` cpp
|
| 370 |
-
namespace A {
|
| 371 |
-
namespace B {
|
| 372 |
-
void f1(int);
|
| 373 |
-
}
|
| 374 |
-
using namespace B;
|
| 375 |
-
}
|
| 376 |
-
void A::f1(int){ } // error: f1 is not a member of A
|
| 377 |
-
```
|
| 378 |
-
|
| 379 |
-
— *end example*]
|
| 380 |
-
|
| 381 |
-
However, in such namespace member declarations, the
|
| 382 |
-
*nested-name-specifier* may rely on *using-directive*s to implicitly
|
| 383 |
-
provide the initial part of the *nested-name-specifier*.
|
| 384 |
-
|
| 385 |
-
[*Example 6*:
|
| 386 |
-
|
| 387 |
-
``` cpp
|
| 388 |
-
namespace A {
|
| 389 |
-
namespace B {
|
| 390 |
-
void f1(int);
|
| 391 |
-
}
|
| 392 |
-
}
|
| 393 |
-
|
| 394 |
-
namespace C {
|
| 395 |
-
namespace D {
|
| 396 |
-
void f1(int);
|
| 397 |
-
}
|
| 398 |
-
}
|
| 399 |
-
|
| 400 |
-
using namespace A;
|
| 401 |
-
using namespace C::D;
|
| 402 |
-
void B::f1(int){ } // OK, defines A::B::f1(int)
|
| 403 |
-
```
|
| 404 |
-
|
| 405 |
-
— *end example*]
|
| 406 |
-
|
|
|
|
| 1 |
### Qualified name lookup <a id="basic.lookup.qual">[[basic.lookup.qual]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="basic.lookup.qual.general">[[basic.lookup.qual.general]]</a>
|
| 4 |
+
|
| 5 |
+
Lookup of an *identifier* followed by a `::` scope resolution operator
|
| 6 |
+
considers only namespaces, types, and templates whose specializations
|
| 7 |
+
are types. If a name, *template-id*, or *decltype-specifier* is followed
|
| 8 |
+
by a `::`, it shall designate a namespace, class, enumeration, or
|
| 9 |
+
dependent type, and the `::` is never interpreted as a complete
|
| 10 |
+
*nested-name-specifier*.
|
|
|
|
| 11 |
|
| 12 |
[*Example 1*:
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
class A {
|
|
|
|
| 19 |
int main() {
|
| 20 |
int A;
|
| 21 |
A::n = 42; // OK
|
| 22 |
A b; // error: A does not name a type
|
| 23 |
}
|
| 24 |
+
template<int> struct B : A {};
|
| 25 |
+
namespace N {
|
| 26 |
+
template<int> void B();
|
| 27 |
+
int f() {
|
| 28 |
+
return B<0>::n; // error: N::B<0> is not a type
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
```
|
| 32 |
|
| 33 |
— *end example*]
|
| 34 |
|
| 35 |
+
A member-qualified name is the (unique) component name
|
| 36 |
+
[[expr.prim.id.unqual]], if any, of
|
| 37 |
+
|
| 38 |
+
- an *unqualified-id* or
|
| 39 |
+
- a *nested-name-specifier* of the form *type-name* `::` or
|
| 40 |
+
*namespace-name* `::`
|
| 41 |
+
|
| 42 |
+
in the *id-expression* of a class member access expression [[expr.ref]].
|
| 43 |
+
A *qualified name* is
|
| 44 |
+
|
| 45 |
+
- a member-qualified name or
|
| 46 |
+
- the terminal name of
|
| 47 |
+
- a *qualified-id*,
|
| 48 |
+
- a *using-declarator*,
|
| 49 |
+
- a *typename-specifier*,
|
| 50 |
+
- a *qualified-namespace-specifier*, or
|
| 51 |
+
- a *nested-name-specifier*, *elaborated-type-specifier*, or
|
| 52 |
+
*class-or-decltype* that has a *nested-name-specifier*
|
| 53 |
+
[[expr.prim.id.qual]].
|
| 54 |
+
|
| 55 |
+
The *lookup context* of a member-qualified name is the type of its
|
| 56 |
+
associated object expression (considered dependent if the object
|
| 57 |
+
expression is type-dependent). The lookup context of any other qualified
|
| 58 |
+
name is the type, template, or namespace nominated by the preceding
|
| 59 |
+
*nested-name-specifier*.
|
| 60 |
+
|
| 61 |
+
[*Note 1*: When parsing a class member access, the name following the
|
| 62 |
+
`->` or `.` is a qualified name even though it is not yet known of which
|
| 63 |
+
kind. — *end note*]
|
| 64 |
|
| 65 |
[*Example 2*:
|
| 66 |
|
| 67 |
+
In
|
| 68 |
+
|
| 69 |
``` cpp
|
| 70 |
+
N::C::m.Base::f()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
```
|
| 72 |
|
| 73 |
+
`Base` is a member-qualified name; the other qualified names are `C`,
|
| 74 |
+
`m`, and `f`.
|
| 75 |
+
|
| 76 |
— *end example*]
|
| 77 |
|
| 78 |
+
*Qualified name lookup* in a class, namespace, or enumeration performs a
|
| 79 |
+
search of the scope associated with it [[class.member.lookup]] except as
|
| 80 |
+
specified below. Unless otherwise specified, a qualified name undergoes
|
| 81 |
+
qualified name lookup in its lookup context from the point where it
|
| 82 |
+
appears unless the lookup context either is dependent and is not the
|
| 83 |
+
current instantiation [[temp.dep.type]] or is not a class or class
|
| 84 |
+
template. If nothing is found by qualified lookup for a member-qualified
|
| 85 |
+
name that is the terminal name [[expr.prim.id.unqual]] of a
|
| 86 |
+
*nested-name-specifier* and is not dependent, it undergoes unqualified
|
| 87 |
+
lookup.
|
| 88 |
+
|
| 89 |
+
[*Note 2*: During lookup for a template specialization, no names are
|
| 90 |
+
dependent. — *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
[*Example 3*:
|
| 93 |
|
| 94 |
+
``` cpp
|
| 95 |
+
int f();
|
| 96 |
+
struct A {
|
| 97 |
+
int B, C;
|
| 98 |
+
template<int> using D = void;
|
| 99 |
+
using T = void;
|
| 100 |
+
void f();
|
| 101 |
+
};
|
| 102 |
+
using B = A;
|
| 103 |
+
template<int> using C = A;
|
| 104 |
+
template<int> using D = A;
|
| 105 |
+
template<int> using X = A;
|
| 106 |
+
|
| 107 |
+
template<class T>
|
| 108 |
+
void g(T *p) { // as instantiated for g<A>:
|
| 109 |
+
p->X<0>::f(); // error: A::X not found in ((p->X) < 0) > ::f()
|
| 110 |
+
p->template X<0>::f(); // OK, ::X found in definition context
|
| 111 |
+
p->B::f(); // OK, non-type A::B ignored
|
| 112 |
+
p->template C<0>::f(); // error: A::C is not a template
|
| 113 |
+
p->template D<0>::f(); // error: A::D<0> is not a class type
|
| 114 |
+
p->T::f(); // error: A::T is not a class type
|
| 115 |
+
}
|
| 116 |
+
template void g(A*);
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
— *end example*]
|
| 120 |
+
|
| 121 |
+
If a qualified name Q follows a `~`:
|
| 122 |
+
|
| 123 |
+
- If Q is a member-qualified name, it undergoes unqualified lookup as
|
| 124 |
+
well as qualified lookup.
|
| 125 |
+
- Otherwise, its *nested-name-specifier* N shall nominate a type. If N
|
| 126 |
+
has another *nested-name-specifier* S, Q is looked up as if its lookup
|
| 127 |
+
context were that nominated by S.
|
| 128 |
+
- Otherwise, if the terminal name of N is a member-qualified name M, Q
|
| 129 |
+
is looked up as if `\~`Q appeared in place of M (as above).
|
| 130 |
+
- Otherwise, Q undergoes unqualified lookup.
|
| 131 |
+
- Each lookup for Q considers only types (if Q is not followed by a `<`)
|
| 132 |
+
and templates whose specializations are types. If it finds nothing or
|
| 133 |
+
is ambiguous, it is discarded.
|
| 134 |
+
- The *type-name* that is or contains Q shall refer to its (original)
|
| 135 |
+
lookup context (ignoring cv-qualification) under the interpretation
|
| 136 |
+
established by at least one (successful) lookup performed.
|
| 137 |
+
|
| 138 |
+
[*Example 4*:
|
| 139 |
+
|
| 140 |
``` cpp
|
| 141 |
struct C {
|
| 142 |
typedef int I;
|
| 143 |
};
|
| 144 |
typedef int I1, I2;
|
| 145 |
extern int* p;
|
| 146 |
extern int* q;
|
| 147 |
+
void f() {
|
| 148 |
p->C::I::~I(); // I is looked up in the scope of C
|
| 149 |
+
q->I1::~I2(); // I2 is found by unqualified lookup
|
| 150 |
+
}
|
| 151 |
struct A {
|
| 152 |
~A();
|
| 153 |
};
|
| 154 |
typedef A AB;
|
| 155 |
int main() {
|
|
|
|
| 158 |
}
|
| 159 |
```
|
| 160 |
|
| 161 |
— *end example*]
|
| 162 |
|
|
|
|
|
|
|
|
|
|
| 163 |
#### Class members <a id="class.qual">[[class.qual]]</a>
|
| 164 |
|
| 165 |
+
In a lookup for a qualified name N whose lookup context is a class C in
|
| 166 |
+
which function names are not ignored,[^4]
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
+
- if the search finds the injected-class-name of `C` [[class.pre]], or
|
| 169 |
+
- if N is dependent and is the terminal name of a *using-declarator*
|
| 170 |
+
[[namespace.udecl]] that names a constructor,
|
| 171 |
|
| 172 |
+
N is instead considered to name the constructor of class `C`. Such a
|
| 173 |
+
constructor name shall be used only in the *declarator-id* of a (friend)
|
| 174 |
+
declaration of a constructor or in a *using-declaration*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
[*Example 1*:
|
| 177 |
|
| 178 |
``` cpp
|
| 179 |
struct A { A(); };
|
|
|
|
| 187 |
struct A::A a2; // object of type A
|
| 188 |
```
|
| 189 |
|
| 190 |
— *end example*]
|
| 191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
#### Namespace members <a id="namespace.qual">[[namespace.qual]]</a>
|
| 193 |
|
| 194 |
+
Qualified name lookup in a namespace N additionally searches every
|
| 195 |
+
element of the inline namespace set of N [[namespace.def]]. If nothing
|
| 196 |
+
is found, the results of the lookup are the results of qualified name
|
| 197 |
+
lookup in each namespace nominated by a *using-directive* that precedes
|
| 198 |
+
the point of the lookup and inhabits N or an element of N’s inline
|
| 199 |
+
namespace set.
|
| 200 |
|
| 201 |
+
[*Note 1*: If a *using-directive* refers to a namespace that has
|
| 202 |
+
already been considered, it does not affect the result. — *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
[*Example 1*:
|
| 205 |
|
| 206 |
``` cpp
|
| 207 |
int x;
|
|
|
|
| 255 |
}
|
| 256 |
```
|
| 257 |
|
| 258 |
— *end example*]
|
| 259 |
|
| 260 |
+
[*Note 2*:
|
| 261 |
|
| 262 |
The same declaration found more than once is not an ambiguity (because
|
| 263 |
it is still a unique declaration).
|
| 264 |
|
| 265 |
[*Example 2*:
|
|
|
|
| 282 |
using namespace C;
|
| 283 |
}
|
| 284 |
|
| 285 |
void f()
|
| 286 |
{
|
| 287 |
+
BC::a++; // OK, S is { `A::a`, `A::a` }
|
| 288 |
}
|
| 289 |
|
| 290 |
namespace D {
|
| 291 |
using A::a;
|
| 292 |
}
|
|
|
|
| 296 |
using namespace D;
|
| 297 |
}
|
| 298 |
|
| 299 |
void g()
|
| 300 |
{
|
| 301 |
+
BD::a++; // OK, S is { `A::a`, `A::a` }
|
| 302 |
}
|
| 303 |
```
|
| 304 |
|
| 305 |
— *end example*]
|
| 306 |
|
|
|
|
| 325 |
using namespace A;
|
| 326 |
}
|
| 327 |
|
| 328 |
void f()
|
| 329 |
{
|
| 330 |
+
A::a++; // OK, a declared directly in A, S is { `A::a` }
|
| 331 |
+
B::a++; // OK, both A and B searched (once), S is { `A::a` }
|
| 332 |
+
A::b++; // OK, both A and B searched (once), S is { `B::b` }
|
| 333 |
+
B::b++; // OK, b declared directly in B, S is { `B::b` }
|
| 334 |
}
|
| 335 |
```
|
| 336 |
|
| 337 |
— *end example*]
|
| 338 |
|
| 339 |
+
[*Note 3*: Class and enumeration declarations are not discarded because
|
| 340 |
+
of other declarations found in other searches. — *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
|
| 342 |
[*Example 4*:
|
| 343 |
|
| 344 |
``` cpp
|
| 345 |
namespace A {
|
|
|
|
| 360 |
}
|
| 361 |
```
|
| 362 |
|
| 363 |
— *end example*]
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|