From Jason Turner

[basic.scope.pdecl]

Diff to HTML by rtfpessoa

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