From Jason Turner

[class.prop]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfgbqpwpz/{from.md → to.md} +65 -13
tmp/tmpfgbqpwpz/{from.md → to.md} RENAMED
@@ -7,16 +7,68 @@ A *trivially copyable class* is a class:
7
  [[special]], [[class.copy.ctor]], [[class.copy.assign]],
8
  - where each eligible copy constructor, move constructor, copy
9
  assignment operator, and move assignment operator is trivial, and
10
  - that has a trivial, non-deleted destructor [[class.dtor]].
11
 
12
- A *trivial class* is a class that is trivially copyable and has one or
13
- more eligible default constructors [[class.default.ctor]], all of which
14
- are trivial.
15
 
16
- [*Note 1*: In particular, a trivially copyable or trivial class does
17
- not have virtual functions or virtual base classes. *end note*]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  A class `S` is a *standard-layout class* if it:
20
 
21
  - has no non-static data members of type non-standard-layout class (or
22
  array of such types) or reference,
@@ -28,11 +80,11 @@ A class `S` is a *standard-layout class* if it:
28
  - has at most one base class subobject of any given type,
29
  - has all non-static data members and bit-fields in the class and its
30
  base classes first declared in the same class, and
31
  - has no element of the set M(S) of types as a base class, where for any
32
  type `X`, M(X) is defined as follows.[^1]
33
- \[*Note 2*: M(X) is the set of the types of all non-base-class
34
  subobjects that can be at a zero offset in `X`. — *end note*]
35
  - If `X` is a non-union class type with no non-static data members,
36
  the set M(X) is empty.
37
  - If `X` is a non-union class type with a non-static data member of
38
  type X₀ that is either of zero size or is the first non-static data
@@ -64,44 +116,44 @@ struct U : S, T { }; // not a standard-layout class
64
  A *standard-layout struct* is a standard-layout class defined with the
65
  *class-key* `struct` or the *class-key* `class`. A
66
  *standard-layout union* is a standard-layout class defined with the
67
  *class-key* `union`.
68
 
69
- [*Note 3*: Standard-layout classes are useful for communicating with
70
  code written in other programming languages. Their layout is specified
71
- in  [[class.mem]]. — *end note*]
72
 
73
  [*Example 2*:
74
 
75
  ``` cpp
76
- struct N { // neither trivial nor standard-layout
77
  int i;
78
  int j;
79
  virtual ~N();
80
  };
81
 
82
- struct T { // trivial but not standard-layout
83
  int i;
84
  private:
85
  int j;
86
  };
87
 
88
- struct SL { // standard-layout but not trivial
89
  int i;
90
  int j;
91
  ~SL();
92
  };
93
 
94
- struct POD { // both trivial and standard-layout
95
  int i;
96
  int j;
97
  };
98
  ```
99
 
100
  — *end example*]
101
 
102
- [*Note 4*: Aggregates of class type are described in 
103
  [[dcl.init.aggr]]. — *end note*]
104
 
105
  A class `S` is an *implicit-lifetime class* if
106
 
107
  - it is an aggregate whose destructor is not user-provided or
 
7
  [[special]], [[class.copy.ctor]], [[class.copy.assign]],
8
  - where each eligible copy constructor, move constructor, copy
9
  assignment operator, and move assignment operator is trivial, and
10
  - that has a trivial, non-deleted destructor [[class.dtor]].
11
 
12
+ A class `C` is *default-movable* if
 
 
13
 
14
+ - overload resolution for direct-initializing an object of type `C` from
15
+ an xvalue of type `C` selects a constructor that is a direct member of
16
+ `C` and is neither user-provided nor deleted,
17
+ - overload resolution for assigning to an lvalue of type `C` from an
18
+ xvalue of type `C` selects an assignment operator function that is a
19
+ direct member of `C` and is neither user-provided nor deleted, and
20
+ - `C` has a destructor that is neither user-provided nor deleted.
21
+
22
+ A class is *eligible for trivial relocation* unless it
23
+
24
+ - has any virtual base classes,
25
+ - has a base class that is not a trivially relocatable class,
26
+ - has a non-static data member of an object type that is not of a
27
+ trivially relocatable type, or
28
+ - has a deleted destructor,
29
+
30
+ except that it is *implementation-defined* whether an otherwise-eligible
31
+ union having one or more subobjects of polymorphic class type is
32
+ eligible for trivial relocation.
33
+
34
+ A class `C` is a *trivially relocatable class* if it is eligible for
35
+ trivial relocation and
36
+
37
+ - has the `trivially_relocatable_if_eligible`
38
+ *class-property-specifier*,
39
+ - is a union with no user-declared special member functions, or
40
+ - is default-movable.
41
+
42
+ [*Note 1*: A class with const-qualified or reference non-static data
43
+ members can be trivially relocatable. — *end note*]
44
+
45
+ A class `C` is *eligible for replacement* unless
46
+
47
+ - it has a base class that is not a replaceable class,
48
+ - it has a non-static data member that is not of a replaceable type,
49
+ - overload resolution fails or selects a deleted constructor when
50
+ direct-initializing an object of type `C` from an xvalue of type `C`
51
+ [[dcl.init.general]],
52
+ - overload resolution fails or selects a deleted assignment operator
53
+ function when assigning to an lvalue of type `C` from an xvalue of
54
+ type `C` [[expr.assign]], [[over.assign]], or
55
+ - it has a deleted destructor.
56
+
57
+ A class `C` is a *replaceable class* if it is eligible for replacement
58
+ and
59
+
60
+ - has the `replaceable_if_eligible` *class-property-specifier*,
61
+ - is a union with no user-declared special member functions, or
62
+ - is default-movable.
63
+
64
+ [*Note 2*: Accessibility of the special member functions is not
65
+ considered when establishing trivial relocatability or
66
+ replaceability. — *end note*]
67
+
68
+ [*Note 3*: Not all trivially copyable classes are trivially relocatable
69
+ or replaceable. — *end note*]
70
 
71
  A class `S` is a *standard-layout class* if it:
72
 
73
  - has no non-static data members of type non-standard-layout class (or
74
  array of such types) or reference,
 
80
  - has at most one base class subobject of any given type,
81
  - has all non-static data members and bit-fields in the class and its
82
  base classes first declared in the same class, and
83
  - has no element of the set M(S) of types as a base class, where for any
84
  type `X`, M(X) is defined as follows.[^1]
85
+ \[*Note 4*: M(X) is the set of the types of all non-base-class
86
  subobjects that can be at a zero offset in `X`. — *end note*]
87
  - If `X` is a non-union class type with no non-static data members,
88
  the set M(X) is empty.
89
  - If `X` is a non-union class type with a non-static data member of
90
  type X₀ that is either of zero size or is the first non-static data
 
116
  A *standard-layout struct* is a standard-layout class defined with the
117
  *class-key* `struct` or the *class-key* `class`. A
118
  *standard-layout union* is a standard-layout class defined with the
119
  *class-key* `union`.
120
 
121
+ [*Note 5*: Standard-layout classes are useful for communicating with
122
  code written in other programming languages. Their layout is specified
123
+ in  [[class.mem.general]] and  [[expr.rel]]. — *end note*]
124
 
125
  [*Example 2*:
126
 
127
  ``` cpp
128
+ struct N { // neither trivially copyable nor standard-layout
129
  int i;
130
  int j;
131
  virtual ~N();
132
  };
133
 
134
+ struct T { // trivially copyable but not standard-layout
135
  int i;
136
  private:
137
  int j;
138
  };
139
 
140
+ struct SL { // standard-layout but not trivially copyable
141
  int i;
142
  int j;
143
  ~SL();
144
  };
145
 
146
+ struct POD { // both trivially copyable and standard-layout
147
  int i;
148
  int j;
149
  };
150
  ```
151
 
152
  — *end example*]
153
 
154
+ [*Note 6*: Aggregates of class type are described in 
155
  [[dcl.init.aggr]]. — *end note*]
156
 
157
  A class `S` is an *implicit-lifetime class* if
158
 
159
  - it is an aggregate whose destructor is not user-provided or