From Jason Turner

[basic.scope.declarative]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpe8bw_s8v/{from.md → to.md} +22 -15
tmp/tmpe8bw_s8v/{from.md → to.md} RENAMED
@@ -11,11 +11,13 @@ scope* of a declaration. The scope of a declaration is the same as its
11
  potential scope unless the potential scope contains another declaration
12
  of the same name. In that case, the potential scope of the declaration
13
  in the inner (contained) declarative region is excluded from the scope
14
  of the declaration in the outer (containing) declarative region.
15
 
16
- in
 
 
17
 
18
  ``` cpp
19
  int j = 24;
20
  int main() {
21
  int i = j, j;
@@ -31,10 +33,12 @@ text between the `,` and the `}`. The declarative region of the second
31
  declaration of `j` (the `j` immediately before the semicolon) includes
32
  all the text between `{` and `}`, but its potential scope excludes the
33
  declaration of `i`. The scope of the second declaration of `j` is the
34
  same as its potential scope.
35
 
 
 
36
  The names declared by a declaration are introduced into the scope in
37
  which the declaration occurs, except that the presence of a `friend`
38
  specifier ([[class.friend]]), certain uses of the
39
  *elaborated-type-specifier* ([[dcl.type.elab]]), and
40
  *using-directive*s ([[namespace.udir]]) alter this general behavior.
@@ -44,23 +48,26 @@ which specifies the same unqualified name,
44
 
45
  - they shall all refer to the same entity, or all refer to functions and
46
  function templates; or
47
  - exactly one declaration shall declare a class name or enumeration name
48
  that is not a typedef name and the other declarations shall all refer
49
- to the same variable or enumerator, or all refer to functions and
50
- function templates; in this case the class name or enumeration name is
51
- hidden ([[basic.scope.hiding]]). A namespace name or a class template
52
- name must be unique in its declarative region ([[namespace.alias]],
53
- Clause  [[temp]]).
 
54
 
55
- These restrictions apply to the declarative region into which a name is
56
- introduced, which is not necessarily the same as the region in which the
57
- declaration occurs. In particular, *elaborated-type-specifier*s (
58
- [[dcl.type.elab]]) and friend declarations ([[class.friend]]) may
 
 
 
 
59
  introduce a (possibly not visible) name into an enclosing namespace;
60
- these restrictions apply to that region. Local extern declarations (
61
- [[basic.link]]) may introduce a name into the declarative region where
62
- the declaration appears and also introduce a (possibly not visible) name
63
- into an enclosing namespace; these restrictions apply to both regions.
64
 
65
- The name lookup rules are summarized in  [[basic.lookup]].
 
66
 
 
11
  potential scope unless the potential scope contains another declaration
12
  of the same name. In that case, the potential scope of the declaration
13
  in the inner (contained) declarative region is excluded from the scope
14
  of the declaration in the outer (containing) declarative region.
15
 
16
+ [*Example 1*:
17
+
18
+ In
19
 
20
  ``` cpp
21
  int j = 24;
22
  int main() {
23
  int i = j, j;
 
33
  declaration of `j` (the `j` immediately before the semicolon) includes
34
  all the text between `{` and `}`, but its potential scope excludes the
35
  declaration of `i`. The scope of the second declaration of `j` is the
36
  same as its potential scope.
37
 
38
+ — *end example*]
39
+
40
  The names declared by a declaration are introduced into the scope in
41
  which the declaration occurs, except that the presence of a `friend`
42
  specifier ([[class.friend]]), certain uses of the
43
  *elaborated-type-specifier* ([[dcl.type.elab]]), and
44
  *using-directive*s ([[namespace.udir]]) alter this general behavior.
 
48
 
49
  - they shall all refer to the same entity, or all refer to functions and
50
  function templates; or
51
  - exactly one declaration shall declare a class name or enumeration name
52
  that is not a typedef name and the other declarations shall all refer
53
+ to the same variable, non-static data member, or enumerator, or all
54
+ refer to functions and function templates; in this case the class name
55
+ or enumeration name is hidden ([[basic.scope.hiding]]). \[*Note 1*: A
56
+ namespace name or a class template name must be unique in its
57
+ declarative region ([[namespace.alias]], Clause 
58
+ [[temp]]). — *end note*]
59
 
60
+ [*Note 2*: These restrictions apply to the declarative region into
61
+ which a name is introduced, which is not necessarily the same as the
62
+ region in which the declaration occurs. In particular,
63
+ *elaborated-type-specifier*s ([[dcl.type.elab]]) and friend
64
+ declarations ([[class.friend]]) may introduce a (possibly not visible)
65
+ name into an enclosing namespace; these restrictions apply to that
66
+ region. Local extern declarations ([[basic.link]]) may introduce a name
67
+ into the declarative region where the declaration appears and also
68
  introduce a (possibly not visible) name into an enclosing namespace;
69
+ these restrictions apply to both regions. *end note*]
 
 
 
70
 
71
+ [*Note 3*: The name lookup rules are summarized in 
72
+ [[basic.lookup]]. — *end note*]
73