From Jason Turner

[class.pre]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpddgqn_9m/{from.md → to.md} +30 -16
tmp/tmpddgqn_9m/{from.md → to.md} RENAMED
@@ -18,22 +18,29 @@ class-specifier:
18
  class-head '{' member-specificationₒₚₜ '}'
19
  ```
20
 
21
  ``` bnf
22
  class-head:
23
- class-key attribute-specifier-seqₒₚₜ class-head-name class-virt-specifierₒₚₜ base-clauseₒₚₜ
24
  class-key attribute-specifier-seqₒₚₜ base-clauseₒₚₜ
25
  ```
26
 
27
  ``` bnf
28
  class-head-name:
29
  nested-name-specifierₒₚₜ class-name
30
  ```
31
 
32
  ``` bnf
33
- class-virt-specifier:
 
 
 
 
 
34
  final
 
 
35
  ```
36
 
37
  ``` bnf
38
  class-key:
39
  class
@@ -43,22 +50,22 @@ class-key:
43
 
44
  A class declaration where the *class-name* in the *class-head-name* is a
45
  *simple-template-id* shall be an explicit specialization
46
  [[temp.expl.spec]] or a partial specialization [[temp.spec.partial]]. A
47
  *class-specifier* whose *class-head* omits the *class-head-name* defines
48
- an unnamed class.
49
 
50
  [*Note 1*: An unnamed class thus can’t be `final`. — *end note*]
51
 
52
  Otherwise, the *class-name* is an *identifier*; it is not looked up, and
53
  the *class-specifier* introduces it.
54
 
55
- The *class-name* is also bound in the scope of the class (template)
56
- itself; this is known as the *injected-class-name*. For purposes of
57
- access checking, the injected-class-name is treated as if it were a
58
- public member name. A *class-specifier* is commonly referred to as a
59
- *class definition*. A class is considered defined after the closing
60
  brace of its *class-specifier* has been seen even though its member
61
  functions are in general not yet defined. The optional
62
  *attribute-specifier-seq* appertains to the class; the attributes in the
63
  *attribute-specifier-seq* are thereafter considered attributes of the
64
  class whenever it is named.
@@ -90,38 +97,45 @@ template<> struct A<void> {}; // OK
90
  [*Note 2*: The *class-key* determines whether the class is a union
91
  [[class.union]] and whether access is public or private by default
92
  [[class.access]]. A union holds the value of at most one data member at
93
  a time. — *end note*]
94
 
95
- If a class is marked with the *class-virt-specifier* `final` and it
96
- appears as a *class-or-decltype* in a *base-clause* [[class.derived]],
97
- the program is ill-formed. Whenever a *class-key* is followed by a
98
- *class-head-name*, the *identifier* `final`, and a colon or left brace,
99
- `final` is interpreted as a *class-virt-specifier*.
 
100
 
101
  [*Example 2*:
102
 
103
  ``` cpp
104
  struct A;
105
  struct A final {}; // OK, definition of struct A,
106
  // not value-initialization of variable final
107
 
108
  struct X {
109
  struct C { constexpr operator int() { return 5; } };
110
- struct B final : C{}; // OK, definition of nested class B,
111
- // not declaration of a bit-field member final
 
 
112
  };
113
  ```
114
 
115
  — *end example*]
116
 
 
 
 
 
117
  [*Note 3*: Complete objects of class type have nonzero size. Base class
118
  subobjects and members declared with the `no_unique_address` attribute
119
  [[dcl.attr.nouniqueaddr]] are not so constrained. — *end note*]
120
 
121
  [*Note 4*: Class objects can be assigned
122
- [[over.ass]], [[class.copy.assign]], passed as arguments to functions
123
  [[dcl.init]], [[class.copy.ctor]], and returned by functions (except
124
  objects of classes for which copying or moving has been restricted; see 
125
  [[dcl.fct.def.delete]] and [[class.access]]). Other plausible operators,
126
  such as equality comparison, can be defined by the user; see 
127
  [[over.oper]]. — *end note*]
 
18
  class-head '{' member-specificationₒₚₜ '}'
19
  ```
20
 
21
  ``` bnf
22
  class-head:
23
+ class-key attribute-specifier-seqₒₚₜ class-head-name class-property-specifier-seqₒₚₜ base-clauseₒₚₜ
24
  class-key attribute-specifier-seqₒₚₜ base-clauseₒₚₜ
25
  ```
26
 
27
  ``` bnf
28
  class-head-name:
29
  nested-name-specifierₒₚₜ class-name
30
  ```
31
 
32
  ``` bnf
33
+ class-property-specifier-seq:
34
+ class-property-specifier class-property-specifier-seqₒₚₜ
35
+ ```
36
+
37
+ ``` bnf
38
+ class-property-specifier:
39
  final
40
+ trivially_relocatable_if_eligible
41
+ replaceable_if_eligible
42
  ```
43
 
44
  ``` bnf
45
  class-key:
46
  class
 
50
 
51
  A class declaration where the *class-name* in the *class-head-name* is a
52
  *simple-template-id* shall be an explicit specialization
53
  [[temp.expl.spec]] or a partial specialization [[temp.spec.partial]]. A
54
  *class-specifier* whose *class-head* omits the *class-head-name* defines
55
+ an *unnamed class*.
56
 
57
  [*Note 1*: An unnamed class thus can’t be `final`. — *end note*]
58
 
59
  Otherwise, the *class-name* is an *identifier*; it is not looked up, and
60
  the *class-specifier* introduces it.
61
 
62
+ The component name of the *class-name* is also bound in the scope of the
63
+ class (template) itself; this is known as the *injected-class-name*. For
64
+ purposes of access checking, the injected-class-name is treated as if it
65
+ were a public member name. A *class-specifier* is commonly referred to
66
+ as a *class definition*. A class is considered defined after the closing
67
  brace of its *class-specifier* has been seen even though its member
68
  functions are in general not yet defined. The optional
69
  *attribute-specifier-seq* appertains to the class; the attributes in the
70
  *attribute-specifier-seq* are thereafter considered attributes of the
71
  class whenever it is named.
 
97
  [*Note 2*: The *class-key* determines whether the class is a union
98
  [[class.union]] and whether access is public or private by default
99
  [[class.access]]. A union holds the value of at most one data member at
100
  a time. — *end note*]
101
 
102
+ Each *class-property-specifier* shall appear at most once within a
103
+ single *class-property-specifier-seq*. Whenever a *class-key* is
104
+ followed by a *class-head-name*, one of the identifiers `final`,
105
+ `trivially_relocatable_if_eligible`, or `replaceable_if_eligible`, and a
106
+ colon or left brace, the identifier is interpreted as a
107
+ *class-property-specifier*.
108
 
109
  [*Example 2*:
110
 
111
  ``` cpp
112
  struct A;
113
  struct A final {}; // OK, definition of struct A,
114
  // not value-initialization of variable final
115
 
116
  struct X {
117
  struct C { constexpr operator int() { return 5; } };
118
+ struct B trivially_relocatable_if_eligible : C{};
119
+ // OK, definition of nested class B,
120
+ // not declaration of a bit-field member
121
+ // trivially_relocatable_if_eligible
122
  };
123
  ```
124
 
125
  — *end example*]
126
 
127
+ If a class is marked with the *class-property-specifier* `final` and
128
+ that class appears as a *class-or-decltype* in a *base-clause*
129
+ [[class.derived]], the program is ill-formed.
130
+
131
  [*Note 3*: Complete objects of class type have nonzero size. Base class
132
  subobjects and members declared with the `no_unique_address` attribute
133
  [[dcl.attr.nouniqueaddr]] are not so constrained. — *end note*]
134
 
135
  [*Note 4*: Class objects can be assigned
136
+ [[over.assign]], [[class.copy.assign]], passed as arguments to functions
137
  [[dcl.init]], [[class.copy.ctor]], and returned by functions (except
138
  objects of classes for which copying or moving has been restricted; see 
139
  [[dcl.fct.def.delete]] and [[class.access]]). Other plausible operators,
140
  such as equality comparison, can be defined by the user; see 
141
  [[over.oper]]. — *end note*]