From Jason Turner

[class.mem.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0cwgvzne/{from.md → to.md} +107 -24
tmp/tmp0cwgvzne/{from.md → to.md} RENAMED
@@ -8,13 +8,15 @@ member-specification:
8
 
9
  ``` bnf
10
  member-declaration:
11
  attribute-specifier-seqₒₚₜ decl-specifier-seqₒₚₜ member-declarator-listₒₚₜ ';'
12
  function-definition
 
13
  using-declaration
14
  using-enum-declaration
15
  static_assert-declaration
 
16
  template-declaration
17
  explicit-specialization
18
  deduction-guide
19
  alias-declaration
20
  opaque-enum-declaration
@@ -27,20 +29,19 @@ member-declarator-list:
27
  member-declarator-list ',' member-declarator
28
  ```
29
 
30
  ``` bnf
31
  member-declarator:
32
- declarator virt-specifier-seqₒₚₜ pure-specifierₒₚₜ
33
- declarator requires-clause
34
- declarator brace-or-equal-initializerₒₚₜ
35
  identifierₒₚₜ attribute-specifier-seqₒₚₜ ':' constant-expression brace-or-equal-initializerₒₚₜ
36
  ```
37
 
38
  ``` bnf
39
  virt-specifier-seq:
40
- virt-specifier
41
- virt-specifier-seq virt-specifier
42
  ```
43
 
44
  ``` bnf
45
  virt-specifier:
46
  override
@@ -50,57 +51,97 @@ virt-specifier:
50
  ``` bnf
51
  pure-specifier:
52
  '=' '0'
53
  ```
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  The *member-specification* in a class definition declares the full set
56
  of members of the class; no member can be added elsewhere. A
57
  *direct member* of a class `X` is a member of `X` that was first
58
  declared within the *member-specification* of `X`, including anonymous
59
  union members [[class.union.anon]] and direct members thereof. Members
60
  of a class are data members, member functions [[class.mfct]], nested
61
  types, enumerators, and member templates [[temp.mem]] and
62
  specializations thereof.
63
 
64
- [*Note 1*: A specialization of a static data member template is a
65
  static data member. A specialization of a member function template is a
66
  member function. A specialization of a member class template is a nested
67
  class. — *end note*]
68
 
69
- A *member-declaration* does not declare new members of the class if it
70
- is
71
 
72
  - a friend declaration [[class.friend]],
73
  - a *deduction-guide* [[temp.deduct.guide]],
74
  - a *template-declaration* whose *declaration* is one of the above,
75
  - a *static_assert-declaration*,
 
76
  - a *using-declaration* [[namespace.udecl]], or
77
  - an *empty-declaration*.
78
 
79
  For any other *member-declaration*, each declared entity that is not an
80
  unnamed bit-field [[class.bit]] is a member of the class, and each such
81
  *member-declaration* shall either declare at least one member name of
82
  the class or declare at least one unnamed bit-field.
83
 
84
- A *data member* is a non-function member introduced by a
85
- *member-declarator*. A *member function* is a member that is a function.
86
- Nested types are classes [[class.name]], [[class.nest]] and enumerations
87
- [[dcl.enum]] declared in the class and arbitrary types declared as
88
- members by use of a typedef declaration [[dcl.typedef]] or
89
- *alias-declaration*. The enumerators of an unscoped enumeration
90
- [[dcl.enum]] defined in the class are members of the class.
 
91
 
92
  A data member or member function may be declared `static` in its
93
  *member-declaration*, in which case it is a *static member* (see 
94
  [[class.static]]) (a *static data member* [[class.static.data]] or
95
  *static member function* [[class.static.mfct]], respectively) of the
96
  class. Any other data member or member function is a *non-static member*
97
  (a *non-static data member* or *non-static member function*
98
  [[class.mfct.non.static]], respectively).
99
 
100
- [*Note 2*: A non-static data member of non-reference type is a member
101
- subobject of a class object [[intro.object]]. *end note*]
 
 
 
 
 
 
 
102
 
103
  A member shall not be declared twice in the *member-specification*,
104
  except that
105
 
106
  - a nested class or member class template can be declared and then later
@@ -120,23 +161,27 @@ non-static data member.
120
  A *complete-class context* of a class (template) is a
121
 
122
  - function body [[dcl.fct.def.general]],
123
  - default argument [[dcl.fct.default]],
124
  - default template argument [[temp.param]],
125
- - *noexcept-specifier* [[except.spec]], or
 
126
  - default member initializer
127
 
128
  within the *member-specification* of the class or class template.
129
 
130
  [*Note 4*: A complete-class context of a nested class is also a
131
  complete-class context of any enclosing class, if the nested class is
132
  defined within the *member-specification* of the enclosing
133
  class. — *end note*]
134
 
135
- A class is regarded as complete where its definition is reachable and
136
- within its complete-class contexts; otherwise it is regarded as
137
- incomplete within its own class *member-specification*.
 
 
 
138
 
139
  In a *member-declarator*, an `=` immediately following the *declarator*
140
  is interpreted as introducing a *pure-specifier* if the *declarator-id*
141
  has function type, otherwise it is interpreted as introducing a
142
  *brace-or-equal-initializer*.
@@ -266,11 +311,11 @@ If `T` is the name of a class, then each of the following shall have a
266
  name different from `T`:
267
 
268
  - every static data member of class `T`;
269
  - every member function of class `T`; \[*Note 9*: This restriction does
270
  not apply to constructors, which do not have names
271
- [[class.ctor]] — *end note*]
272
  - every member of class `T` that is itself a type;
273
  - every member template of class `T`;
274
  - every enumerator of every member of class `T` that is an unscoped
275
  enumeration type; and
276
  - every member of every anonymous union that is a member of class `T`.
@@ -285,12 +330,13 @@ and bit-fields in declaration order, starting with the first such entity
285
  in each of the structs, such that
286
 
287
  - corresponding entities have layout-compatible types [[basic.types]],
288
  - corresponding entities have the same alignment requirements
289
  [[basic.align]],
290
- - either both entities are declared with the `no_unique_address`
291
- attribute [[dcl.attr.nouniqueaddr]] or neither is, and
 
292
  - either both entities are bit-fields with the same width or neither is
293
  a bit-field.
294
 
295
  [*Example 4*:
296
 
@@ -353,5 +399,42 @@ alignment. — *end note*]
353
 
354
  [*Note 12*: The object and its first subobject are
355
  pointer-interconvertible
356
  [[basic.compound]], [[expr.static.cast]]. — *end note*]
357
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  ``` bnf
10
  member-declaration:
11
  attribute-specifier-seqₒₚₜ decl-specifier-seqₒₚₜ member-declarator-listₒₚₜ ';'
12
  function-definition
13
+ friend-type-declaration
14
  using-declaration
15
  using-enum-declaration
16
  static_assert-declaration
17
+ consteval-block-declaration
18
  template-declaration
19
  explicit-specialization
20
  deduction-guide
21
  alias-declaration
22
  opaque-enum-declaration
 
29
  member-declarator-list ',' member-declarator
30
  ```
31
 
32
  ``` bnf
33
  member-declarator:
34
+ declarator virt-specifier-seqₒₚₜ function-contract-specifier-seqₒₚₜ pure-specifierₒₚₜ
35
+ declarator requires-clause function-contract-specifier-seqₒₚₜ
36
+ declarator brace-or-equal-initializer
37
  identifierₒₚₜ attribute-specifier-seqₒₚₜ ':' constant-expression brace-or-equal-initializerₒₚₜ
38
  ```
39
 
40
  ``` bnf
41
  virt-specifier-seq:
42
+ virt-specifier virt-specifier-seqₒₚₜ
 
43
  ```
44
 
45
  ``` bnf
46
  virt-specifier:
47
  override
 
51
  ``` bnf
52
  pure-specifier:
53
  '=' '0'
54
  ```
55
 
56
+ ``` bnf
57
+ friend-type-declaration:
58
+ friend friend-type-specifier-list ';'
59
+ ```
60
+
61
+ ``` bnf
62
+ friend-type-specifier-list:
63
+ friend-type-specifier '...'ₒₚₜ
64
+ friend-type-specifier-list ',' friend-type-specifier '...'ₒₚₜ
65
+ ```
66
+
67
+ ``` bnf
68
+ friend-type-specifier:
69
+ simple-type-specifier
70
+ elaborated-type-specifier
71
+ typename-specifier
72
+ ```
73
+
74
+ In the absence of a *virt-specifier-seq*, the token sequence `= 0` is
75
+ treated as a *pure-specifier* if the type of the *declarator-id*
76
+ [[dcl.meaning.general]] is a function type, and is otherwise treated as
77
+ a *brace-or-equal-initializer*.
78
+
79
+ [*Note 1*: If the member declaration acquires a function type through
80
+ template instantiation, the program is ill-formed; see 
81
+ [[temp.spec.general]]. — *end note*]
82
+
83
+ The optional *function-contract-specifier-seq* [[dcl.contract.func]] in
84
+ a *member-declarator* shall be present only if the *declarator* declares
85
+ a function.
86
+
87
  The *member-specification* in a class definition declares the full set
88
  of members of the class; no member can be added elsewhere. A
89
  *direct member* of a class `X` is a member of `X` that was first
90
  declared within the *member-specification* of `X`, including anonymous
91
  union members [[class.union.anon]] and direct members thereof. Members
92
  of a class are data members, member functions [[class.mfct]], nested
93
  types, enumerators, and member templates [[temp.mem]] and
94
  specializations thereof.
95
 
96
+ [*Note 2*: A specialization of a static data member template is a
97
  static data member. A specialization of a member function template is a
98
  member function. A specialization of a member class template is a nested
99
  class. — *end note*]
100
 
101
+ A *member-declaration* does not itself declare new members of the class
102
+ if it is
103
 
104
  - a friend declaration [[class.friend]],
105
  - a *deduction-guide* [[temp.deduct.guide]],
106
  - a *template-declaration* whose *declaration* is one of the above,
107
  - a *static_assert-declaration*,
108
+ - a *consteval-block-declaration*,
109
  - a *using-declaration* [[namespace.udecl]], or
110
  - an *empty-declaration*.
111
 
112
  For any other *member-declaration*, each declared entity that is not an
113
  unnamed bit-field [[class.bit]] is a member of the class, and each such
114
  *member-declaration* shall either declare at least one member name of
115
  the class or declare at least one unnamed bit-field.
116
 
117
+ A *data member* is either a non-function member introduced by a
118
+ *member-declarator* or an anonymous union member. A *member function* is
119
+ a member that is a function. Nested types are classes
120
+ [[class.name]], [[class.nest]] and enumerations [[dcl.enum]] declared in
121
+ the class and arbitrary types declared as members by use of a typedef
122
+ declaration [[dcl.typedef]] or *alias-declaration*. The enumerators of
123
+ an unscoped enumeration [[dcl.enum]] defined in the class are members of
124
+ the class.
125
 
126
  A data member or member function may be declared `static` in its
127
  *member-declaration*, in which case it is a *static member* (see 
128
  [[class.static]]) (a *static data member* [[class.static.data]] or
129
  *static member function* [[class.static.mfct]], respectively) of the
130
  class. Any other data member or member function is a *non-static member*
131
  (a *non-static data member* or *non-static member function*
132
  [[class.mfct.non.static]], respectively).
133
 
134
+ Every object of class type has a unique member subobject corresponding
135
+ to each of its direct non-static data members. If any non-static data
136
+ member of a class `C` is of reference type, then let `D` be an invented
137
+ class that is identical to `C` except that each non-static member of `D`
138
+ corresponding to a member of `C` of type “reference to `T`” instead has
139
+ type “pointer to `T`”. Every member subobject of a complete object of
140
+ type `C` has the same size, alignment, and offset as that of the
141
+ corresponding subobject of a complete object of type `D`. The size and
142
+ alignment of `C` are the same as the size and alignment of `D`.
143
 
144
  A member shall not be declared twice in the *member-specification*,
145
  except that
146
 
147
  - a nested class or member class template can be declared and then later
 
161
  A *complete-class context* of a class (template) is a
162
 
163
  - function body [[dcl.fct.def.general]],
164
  - default argument [[dcl.fct.default]],
165
  - default template argument [[temp.param]],
166
+ - *noexcept-specifier* [[except.spec]],
167
+ - *function-contract-specifier* [[dcl.contract.func]], or
168
  - default member initializer
169
 
170
  within the *member-specification* of the class or class template.
171
 
172
  [*Note 4*: A complete-class context of a nested class is also a
173
  complete-class context of any enclosing class, if the nested class is
174
  defined within the *member-specification* of the enclosing
175
  class. — *end note*]
176
 
177
+ A class `C` is complete at a program point P if the definition of `C` is
178
+ reachable from P [[module.reach]] or if P is in a complete-class context
179
+ of `C`. Otherwise, `C` is incomplete at P.
180
+
181
+ If a *member-declaration* matches the syntactic requirements of
182
+ *friend-type-declaration*, it is a *friend-type-declaration*.
183
 
184
  In a *member-declarator*, an `=` immediately following the *declarator*
185
  is interpreted as introducing a *pure-specifier* if the *declarator-id*
186
  has function type, otherwise it is interpreted as introducing a
187
  *brace-or-equal-initializer*.
 
311
  name different from `T`:
312
 
313
  - every static data member of class `T`;
314
  - every member function of class `T`; \[*Note 9*: This restriction does
315
  not apply to constructors, which do not have names
316
+ [[class.ctor]]. — *end note*]
317
  - every member of class `T` that is itself a type;
318
  - every member template of class `T`;
319
  - every enumerator of every member of class `T` that is an unscoped
320
  enumeration type; and
321
  - every member of every anonymous union that is a member of class `T`.
 
330
  in each of the structs, such that
331
 
332
  - corresponding entities have layout-compatible types [[basic.types]],
333
  - corresponding entities have the same alignment requirements
334
  [[basic.align]],
335
+ - if a *has-attribute-expression* [[cpp.cond]] is not `0` for the
336
+ `no_unique_address` attribute, then neither entity is declared with
337
+ the `no_unique_address` attribute [[dcl.attr.nouniqueaddr]], and
338
  - either both entities are bit-fields with the same width or neither is
339
  a bit-field.
340
 
341
  [*Example 4*:
342
 
 
399
 
400
  [*Note 12*: The object and its first subobject are
401
  pointer-interconvertible
402
  [[basic.compound]], [[expr.static.cast]]. — *end note*]
403
 
404
+ A *data member description* is a quintuple (T, N, A, W, NUA) describing
405
+ the potential declaration of a non-static data member where
406
+
407
+ - T is a type,
408
+ - N is an *identifier* or $\bot$,
409
+ - A is an alignment or $\bot$,
410
+ - W is a bit-field width or $\bot$, and
411
+ - NUA is a boolean value.
412
+
413
+ Two data member descriptions are equal if each of their respective
414
+ components are the same entities, are the same identifiers, have equal
415
+ values, or are both $\bot$.
416
+
417
+ [*Note 13*:
418
+
419
+ The components of a data member description describe a data member such
420
+ that
421
+
422
+ - its type is specified using the type given by T,
423
+ - it is declared with the name given by N if N is not $\bot$ and is
424
+ otherwise unnamed,
425
+ - it is declared with the *alignment-specifier* [[dcl.align]] given by
426
+ `alignas(A)` if A is not $\bot$ and is otherwise declared without an
427
+ *alignment-specifier*,
428
+ - it is a bit-field [[class.bit]] with the width given by W if W is not
429
+ $\bot$ and is otherwise not a bit-field, and
430
+ - it is declared with the attribute `[[no_unique_address]]`
431
+ [[dcl.attr.nouniqueaddr]] if NUA is true and is otherwise declared
432
+ without that attribute.
433
+
434
+ Data member descriptions are represented by reflections
435
+ [[basic.fundamental]] returned by `std::meta::data_member_spec`
436
+ [[meta.reflection.define.aggregate]] and can be reified as data members
437
+ of a class using `std::meta::define_aggregate`.
438
+
439
+ — *end note*]
440
+