From Jason Turner

[class.prop]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpi1m9rgrd/{from.md → to.md} +108 -0
tmp/tmpi1m9rgrd/{from.md → to.md} RENAMED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Properties of classes <a id="class.prop">[[class.prop]]</a>
2
+
3
+ A *trivially copyable class* is a class:
4
+
5
+ - that has at least one eligible copy constructor, move constructor,
6
+ copy assignment operator, or move assignment operator ([[special]],
7
+ [[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,
23
+ - has no virtual functions [[class.virtual]] and no virtual base classes
24
+ [[class.mi]],
25
+ - has the same access control [[class.access]] for all non-static data
26
+ members,
27
+ - has no non-standard-layout base classes,
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 may be at a zero offset in `X`. — *end note*]
35
+ - If `X` is a non-union class type with no (possibly inherited
36
+ [[class.derived]]) non-static data members, 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
39
+ member of `X` (where said member may be an anonymous union), the set
40
+ M(X) consists of X₀ and the elements of M(X₀).
41
+ - If `X` is a union type, the set M(X) is the union of all M(Uᵢ) and
42
+ the set containing all Uᵢ, where each Uᵢ is the type of the iᵗʰ
43
+ non-static data member of `X`.
44
+ - If `X` is an array type with element type Xₑ, the set M(X) consists
45
+ of Xₑ and the elements of M(Xₑ).
46
+ - If `X` is a non-class, non-array type, the set M(X) is empty.
47
+
48
+ [*Example 1*:
49
+
50
+ ``` cpp
51
+ struct B { int i; }; // standard-layout class
52
+ struct C : B { }; // standard-layout class
53
+ struct D : C { }; // standard-layout class
54
+ struct E : D { char : 4; }; // not a standard-layout class
55
+
56
+ struct Q {};
57
+ struct S : Q { };
58
+ struct T : Q { };
59
+ struct U : S, T { }; // not a standard-layout class
60
+ ```
61
+
62
+ — *end example*]
63
+
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 it is an aggregate or has
106
+ at least one trivial eligible constructor and a trivial, non-deleted
107
+ destructor.
108
+