From Jason Turner

[basic.scope.class]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmparvv8v1f/{from.md → to.md} +50 -1
tmp/tmparvv8v1f/{from.md → to.md} RENAMED
@@ -1,8 +1,57 @@
1
  ### Class scope <a id="basic.scope.class">[[basic.scope.class]]</a>
2
 
3
- The following rules describe the scope of names declared in classes.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  The name of a class member shall only be used as follows:
6
 
7
  - in the scope of its class (as described above) or a class derived
8
  (Clause  [[class.derived]]) from its class,
 
1
  ### Class scope <a id="basic.scope.class">[[basic.scope.class]]</a>
2
 
3
+ The potential scope of a name declared in a class consists not only of
4
+ the declarative region following the name’s point of declaration, but
5
+ also of all function bodies, default arguments, *noexcept-specifier*s,
6
+ and *brace-or-equal-initializer*s of non-static data members in that
7
+ class (including such things in nested classes).
8
+
9
+ A name `N` used in a class `S` shall refer to the same declaration in
10
+ its context and when re-evaluated in the completed scope of `S`. No
11
+ diagnostic is required for a violation of this rule.
12
+
13
+ A name declared within a member function hides a declaration of the same
14
+ name whose scope extends to or past the end of the member function’s
15
+ class.
16
+
17
+ The potential scope of a declaration that extends to or past the end of
18
+ a class definition also extends to the regions defined by its member
19
+ definitions, even if the members are defined lexically outside the class
20
+ (this includes static data member definitions, nested class definitions,
21
+ and member function definitions, including the member function body and
22
+ any portion of the declarator part of such definitions which follows the
23
+ *declarator-id*, including a *parameter-declaration-clause* and any
24
+ default arguments ([[dcl.fct.default]])).
25
+
26
+ [*Example 1*:
27
+
28
+ ``` cpp
29
+ typedef int c;
30
+ enum { i = 1 };
31
+
32
+ class X {
33
+ char v[i]; // error: i refers to ::i but when reevaluated is X::i
34
+ int f() { return sizeof(c); } // OK: X::c
35
+ char c;
36
+ enum { i = 2 };
37
+ };
38
+
39
+ typedef char* T;
40
+ struct Y {
41
+ T a; // error: T refers to ::T but when reevaluated is Y::T
42
+ typedef long T;
43
+ T b;
44
+ };
45
+
46
+ typedef int I;
47
+ class D {
48
+ typedef I I; // error, even though no reordering involved
49
+ };
50
+ ```
51
+
52
+ — *end example*]
53
 
54
  The name of a class member shall only be used as follows:
55
 
56
  - in the scope of its class (as described above) or a class derived
57
  (Clause  [[class.derived]]) from its class,