From Jason Turner

[basic.scope.pdecl]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpnebm1cib/{from.md → to.md} +43 -15
tmp/tmpnebm1cib/{from.md → to.md} RENAMED
@@ -2,62 +2,83 @@
2
 
3
  The *point of declaration* for a name is immediately after its complete
4
  declarator (Clause  [[dcl.decl]]) and before its *initializer* (if any),
5
  except as noted below.
6
 
 
 
7
  ``` cpp
8
  unsigned char x = 12;
9
  { unsigned char x = x; }
10
  ```
11
 
12
  Here the second `x` is initialized with its own (indeterminate) value.
13
 
 
 
 
 
14
  a name from an outer scope remains visible up to the point of
15
  declaration of the name that hides it.
16
 
 
 
17
  ``` cpp
18
  const int i = 2;
19
  { int i[i]; }
20
  ```
21
 
22
  declares a block-scope array of two integers.
23
 
 
 
 
 
24
  The point of declaration for a class or class template first declared by
25
  a *class-specifier* is immediately after the *identifier* or
26
  *simple-template-id* (if any) in its *class-head* (Clause  [[class]]).
27
  The point of declaration for an enumeration is immediately after the
28
  *identifier* (if any) in either its *enum-specifier* ([[dcl.enum]]) or
29
  its first *opaque-enum-declaration* ([[dcl.enum]]), whichever comes
30
  first. The point of declaration of an alias or alias template
31
  immediately follows the *type-id* to which the alias refers.
32
 
33
- The point of declaration of a *using-declaration* that does not name a
34
- constructor is immediately after the *using-declaration* (
35
  [[namespace.udecl]]).
36
 
37
  The point of declaration for an enumerator is immediately after its
38
  *enumerator-definition*.
39
 
 
 
40
  ``` cpp
41
  const int x = 12;
42
  { enum { x = x }; }
43
  ```
44
 
45
  Here, the enumerator `x` is initialized with the value of the constant
46
  `x`, namely 12.
47
 
 
 
48
  After the point of declaration of a class member, the member name can be
49
- looked up in the scope of its class. this is true even if the class is
50
- an incomplete class. For example,
 
 
 
51
 
52
  ``` cpp
53
  struct X {
54
  enum E { z = 16 };
55
  int b[X::z]; // OK
56
  };
57
  ```
58
 
 
 
59
  The point of declaration of a class first declared in an
60
  *elaborated-type-specifier* is as follows:
61
 
62
  - for a declaration of the form
63
  ``` bnf
@@ -74,14 +95,15 @@ The point of declaration of a class first declared in an
74
  if the *elaborated-type-specifier* is used in the *decl-specifier-seq*
75
  or *parameter-declaration-clause* of a function defined in namespace
76
  scope, the *identifier* is declared as a *class-name* in the namespace
77
  that contains the declaration; otherwise, except as a friend
78
  declaration, the *identifier* is declared in the smallest namespace or
79
- block scope that contains the declaration. These rules also apply
80
- within templates. Other forms of *elaborated-type-specifier* do not
81
- declare a new name, and therefore must refer to an existing
82
- *type-name*. See  [[basic.lookup.elab]] and  [[dcl.type.elab]].
 
83
 
84
  The point of declaration for an *injected-class-name* (Clause 
85
  [[class]]) is immediately following the opening brace of the class
86
  definition.
87
 
@@ -90,22 +112,28 @@ The point of declaration for a function-local predefined variable (
90
  definition.
91
 
92
  The point of declaration for a template parameter is immediately after
93
  its complete *template-parameter*.
94
 
 
 
95
  ``` cpp
96
  typedef unsigned char T;
97
  template<class T
98
  = T // lookup finds the typedef name of unsigned char
99
  , T // lookup finds the template parameter
100
  N = 0> struct A { };
101
  ```
102
 
103
- Friend declarations refer to functions or classes that are members of
104
- the nearest enclosing namespace, but they do not introduce new names
105
- into that namespace ([[namespace.memdef]]). Function declarations at
106
- block scope and variable declarations with the `extern` specifier at
107
- block scope refer to declarations that are members of an enclosing
108
- namespace, but they do not introduce new names into that scope.
109
 
110
- For point of instantiation of a template, see  [[temp.point]].
 
 
 
 
 
 
 
 
 
111
 
 
2
 
3
  The *point of declaration* for a name is immediately after its complete
4
  declarator (Clause  [[dcl.decl]]) and before its *initializer* (if any),
5
  except as noted below.
6
 
7
+ [*Example 1*:
8
+
9
  ``` cpp
10
  unsigned char x = 12;
11
  { unsigned char x = x; }
12
  ```
13
 
14
  Here the second `x` is initialized with its own (indeterminate) value.
15
 
16
+ — *end example*]
17
+
18
+ [*Note 1*:
19
+
20
  a name from an outer scope remains visible up to the point of
21
  declaration of the name that hides it.
22
 
23
+ [*Example 2*:
24
+
25
  ``` cpp
26
  const int i = 2;
27
  { int i[i]; }
28
  ```
29
 
30
  declares a block-scope array of two integers.
31
 
32
+ — *end example*]
33
+
34
+ — *end note*]
35
+
36
  The point of declaration for a class or class template first declared by
37
  a *class-specifier* is immediately after the *identifier* or
38
  *simple-template-id* (if any) in its *class-head* (Clause  [[class]]).
39
  The point of declaration for an enumeration is immediately after the
40
  *identifier* (if any) in either its *enum-specifier* ([[dcl.enum]]) or
41
  its first *opaque-enum-declaration* ([[dcl.enum]]), whichever comes
42
  first. The point of declaration of an alias or alias template
43
  immediately follows the *type-id* to which the alias refers.
44
 
45
+ The point of declaration of a *using-declarator* that does not name a
46
+ constructor is immediately after the *using-declarator* (
47
  [[namespace.udecl]]).
48
 
49
  The point of declaration for an enumerator is immediately after its
50
  *enumerator-definition*.
51
 
52
+ [*Example 3*:
53
+
54
  ``` cpp
55
  const int x = 12;
56
  { enum { x = x }; }
57
  ```
58
 
59
  Here, the enumerator `x` is initialized with the value of the constant
60
  `x`, namely 12.
61
 
62
+ — *end example*]
63
+
64
  After the point of declaration of a class member, the member name can be
65
+ looked up in the scope of its class.
66
+
67
+ [*Note 2*:
68
+
69
+ This is true even if the class is an incomplete class. For example,
70
 
71
  ``` cpp
72
  struct X {
73
  enum E { z = 16 };
74
  int b[X::z]; // OK
75
  };
76
  ```
77
 
78
+ — *end note*]
79
+
80
  The point of declaration of a class first declared in an
81
  *elaborated-type-specifier* is as follows:
82
 
83
  - for a declaration of the form
84
  ``` bnf
 
95
  if the *elaborated-type-specifier* is used in the *decl-specifier-seq*
96
  or *parameter-declaration-clause* of a function defined in namespace
97
  scope, the *identifier* is declared as a *class-name* in the namespace
98
  that contains the declaration; otherwise, except as a friend
99
  declaration, the *identifier* is declared in the smallest namespace or
100
+ block scope that contains the declaration.
101
+ \[*Note 3*: These rules also apply within templates. *end note*]
102
+ \[*Note 4*: Other forms of *elaborated-type-specifier* do not declare
103
+ a new name, and therefore must refer to an existing *type-name*. See 
104
+ [[basic.lookup.elab]] and  [[dcl.type.elab]]. — *end note*]
105
 
106
  The point of declaration for an *injected-class-name* (Clause 
107
  [[class]]) is immediately following the opening brace of the class
108
  definition.
109
 
 
112
  definition.
113
 
114
  The point of declaration for a template parameter is immediately after
115
  its complete *template-parameter*.
116
 
117
+ [*Example 4*:
118
+
119
  ``` cpp
120
  typedef unsigned char T;
121
  template<class T
122
  = T // lookup finds the typedef name of unsigned char
123
  , T // lookup finds the template parameter
124
  N = 0> struct A { };
125
  ```
126
 
127
+ *end example*]
 
 
 
 
 
128
 
129
+ [*Note 5*: Friend declarations refer to functions or classes that are
130
+ members of the nearest enclosing namespace, but they do not introduce
131
+ new names into that namespace ([[namespace.memdef]]). Function
132
+ declarations at block scope and variable declarations with the `extern`
133
+ specifier at block scope refer to declarations that are members of an
134
+ enclosing namespace, but they do not introduce new names into that
135
+ scope. — *end note*]
136
+
137
+ [*Note 6*: For point of instantiation of a template, see 
138
+ [[temp.point]]. — *end note*]
139