tmp/tmpnvibiq5g/{from.md → to.md}
RENAMED
|
@@ -1,63 +1,30 @@
|
|
| 1 |
### Class scope <a id="basic.scope.class">[[basic.scope.class]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
its context and when re-evaluated in the completed scope of `S`. No
|
| 9 |
-
diagnostic is required for a violation of this rule.
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
class.
|
| 14 |
-
|
| 15 |
-
The potential scope of a declaration in a class that extends to or past
|
| 16 |
-
the end of a class definition also extends to the regions defined by its
|
| 17 |
-
member definitions, even if the members are defined lexically outside
|
| 18 |
-
the class (this includes static data member definitions, nested class
|
| 19 |
-
definitions, and member function definitions, including the member
|
| 20 |
-
function body and any portion of the declarator part of such definitions
|
| 21 |
-
which follows the *declarator-id*, including a
|
| 22 |
-
*parameter-declaration-clause* and any default arguments
|
| 23 |
-
[[dcl.fct.default]]).
|
| 24 |
|
| 25 |
[*Example 1*:
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
class X {
|
| 32 |
-
char v[i]; // error: i refers to ::i but when reevaluated is X::i
|
| 33 |
-
int f() { return sizeof(c); } // OK: X::c
|
| 34 |
-
char c;
|
| 35 |
-
enum { i = 2 };
|
| 36 |
-
};
|
| 37 |
-
|
| 38 |
-
typedef char* T;
|
| 39 |
-
struct Y {
|
| 40 |
-
T a; // error: T refers to ::T but when reevaluated is Y::T
|
| 41 |
-
typedef long T;
|
| 42 |
-
T b;
|
| 43 |
};
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
typedef I I; // error, even though no reordering involved
|
| 48 |
-
};
|
| 49 |
```
|
| 50 |
|
| 51 |
— *end example*]
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
- in the scope of its class (as described above) or a class derived
|
| 56 |
-
[[class.derived]] from its class,
|
| 57 |
-
- after the `.` operator applied to an expression of the type of its
|
| 58 |
-
class [[expr.ref]] or a class derived from its class,
|
| 59 |
-
- after the `->` operator applied to a pointer to an object of its class
|
| 60 |
-
[[expr.ref]] or a class derived from its class,
|
| 61 |
-
- after the `::` scope resolution operator [[expr.prim.id.qual]] applied
|
| 62 |
-
to the name of its class or a class derived from its class.
|
| 63 |
|
|
|
|
| 1 |
### Class scope <a id="basic.scope.class">[[basic.scope.class]]</a>
|
| 2 |
|
| 3 |
+
Any declaration of a class or class template C introduces a
|
| 4 |
+
*class scope* that includes the *member-specification* of the
|
| 5 |
+
*class-specifier* for C (if any). For each non-friend redeclaration or
|
| 6 |
+
specialization whose target scope is or is contained by the scope, the
|
| 7 |
+
portion after the *declarator-id*, *class-head-name*, or
|
| 8 |
+
*enum-head-name* is also included in the scope.
|
| 9 |
|
| 10 |
+
[*Note 1*:
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
Lookup from a program point before the *class-specifier* of a class will
|
| 13 |
+
find no bindings in the class scope.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
[*Example 1*:
|
| 16 |
|
| 17 |
``` cpp
|
| 18 |
+
template<class D>
|
| 19 |
+
struct B {
|
| 20 |
+
D::type x; // #1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
};
|
| 22 |
|
| 23 |
+
struct A { using type = int; };
|
| 24 |
+
struct C : A, B<C> {}; // error at #1: C::type not found
|
|
|
|
|
|
|
| 25 |
```
|
| 26 |
|
| 27 |
— *end example*]
|
| 28 |
|
| 29 |
+
— *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|