From Jason Turner

[intro.object]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4cvryknk/{from.md → to.md} +31 -29
tmp/tmp4cvryknk/{from.md → to.md} RENAMED
@@ -3,27 +3,27 @@
3
  The constructs in a C++ program create, destroy, refer to, access, and
4
  manipulate objects. An *object* is created by a definition
5
  [[basic.def]], by a *new-expression* [[expr.new]], by an operation that
6
  implicitly creates objects (see below), when implicitly changing the
7
  active member of a union [[class.union]], or when a temporary object is
8
- created ([[conv.rval]], [[class.temporary]]). An object occupies a
9
- region of storage in its period of construction [[class.cdtor]],
10
- throughout its lifetime [[basic.life]], and in its period of destruction
11
  [[class.cdtor]].
12
 
13
  [*Note 1*: A function is not an object, regardless of whether or not it
14
  occupies storage in the way that objects do. — *end note*]
15
 
16
  The properties of an object are determined when the object is created.
17
  An object can have a name [[basic.pre]]. An object has a storage
18
  duration [[basic.stc]] which influences its lifetime [[basic.life]]. An
19
- object has a type [[basic.types]]. Some objects are polymorphic
20
- [[class.virtual]]; the implementation generates information associated
21
- with each such object that makes it possible to determine that object’s
22
- type during program execution. For other objects, the interpretation of
23
- the values found therein is determined by the type of the *expression*s
24
- [[expr.compound]] used to access them.
25
 
26
  Objects can contain other objects, called *subobjects*. A subobject can
27
  be a *member subobject* [[class.mem]], a *base class subobject*
28
  [[class.derived]], or an array element. An object that is not a
29
  subobject of any other object is called a *complete object*. If an
@@ -41,13 +41,14 @@ another object *e* of type “array of N `unsigned char`” or of type
41
  “array of N `std::byte`” [[cstddef.syn]], that array *provides storage*
42
  for the created object if:
43
 
44
  - the lifetime of *e* has begun and not ended, and
45
  - the storage for the new object fits entirely within *e*, and
46
- - there is no smaller array object that satisfies these constraints.
 
47
 
48
- [*Note 2*: If that portion of the array previously provided storage for
49
  another object, the lifetime of that object ends because its storage was
50
  reused [[basic.life]]. — *end note*]
51
 
52
  [*Example 1*:
53
 
@@ -88,12 +89,12 @@ of* `x`, determined as follows:
88
  - If `x` is a complete object, then the complete object of `x` is
89
  itself.
90
  - Otherwise, the complete object of `x` is the complete object of the
91
  (unique) object that contains `x`.
92
 
93
- If a complete object, a data member [[class.mem]], or an array element
94
- is of class type, its type is considered the *most derived class*, to
95
  distinguish it from the class type of any base class subobject; an
96
  object of a most derived class type or of a non-class type is called a
97
  *most derived object*.
98
 
99
  A *potentially-overlapping subobject* is either:
@@ -106,27 +107,28 @@ An object has nonzero size if it
106
 
107
  - is not a potentially-overlapping subobject, or
108
  - is not of class type, or
109
  - is of a class type with virtual member functions or virtual base
110
  classes, or
111
- - has subobjects of nonzero size or bit-fields of nonzero length.
 
112
 
113
  Otherwise, if the object is a base class subobject of a standard-layout
114
  class type with no non-static data members, it has zero size. Otherwise,
115
  the circumstances under which the object has zero size are
116
  *implementation-defined*. Unless it is a bit-field [[class.bit]], an
117
  object with nonzero size shall occupy one or more bytes of storage,
118
  including every byte that is occupied in full or in part by any of its
119
  subobjects. An object of trivially copyable or standard-layout type
120
- [[basic.types]] shall occupy contiguous bytes of storage.
121
 
122
  Unless an object is a bit-field or a subobject of zero size, the address
123
  of that object is the address of the first byte it occupies. Two objects
124
  with overlapping lifetimes that are not bit-fields may have the same
125
  address if one is nested within the other, or if at least one is a
126
  subobject of zero size and they are of different types; otherwise, they
127
- have distinct addresses and occupy disjoint bytes of storage.[^10]
128
 
129
  [*Example 2*:
130
 
131
  ``` cpp
132
  static const char test1 = 'x';
@@ -142,18 +144,18 @@ subobject.
142
 
143
  Some operations are described as *implicitly creating objects* within a
144
  specified region of storage. For each operation that is specified as
145
  implicitly creating objects, that operation implicitly creates and
146
  starts the lifetime of zero or more objects of implicit-lifetime types
147
- [[basic.types]] in its specified region of storage if doing so would
148
- result in the program having defined behavior. If no such set of objects
149
- would give the program defined behavior, the behavior of the program is
150
- undefined. If multiple such sets of objects would give the program
151
- defined behavior, it is unspecified which such set of objects is
152
  created.
153
 
154
- [*Note 3*: Such operations do not start the lifetimes of subobjects of
155
  such objects that are not themselves of implicit-lifetime
156
  types. — *end note*]
157
 
158
  Further, after implicitly creating objects within a specified region of
159
  storage, some operations are described as producing a pointer to a
@@ -184,20 +186,20 @@ X *make_x() {
184
  }
185
  ```
186
 
187
  — *end example*]
188
 
189
- An operation that begins the lifetime of an array of `char`,
190
- `unsigned char`, or `std::byte` implicitly creates objects within the
191
- region of storage occupied by the array.
192
 
193
- [*Note 4*: The array object provides storage for these
194
  objects. — *end note*]
195
 
196
  Any implicit or explicit invocation of a function named `operator new`
197
  or `operator new[]` implicitly creates objects in the returned region of
198
  storage and returns a pointer to a suitable created object.
199
 
200
- [*Note 5*: Some functions in the C++ standard library implicitly create
201
- objects ([[allocator.traits.members]], [[c.malloc]], [[cstring.syn]],
202
- [[bit.cast]]). — *end note*]
203
 
 
3
  The constructs in a C++ program create, destroy, refer to, access, and
4
  manipulate objects. An *object* is created by a definition
5
  [[basic.def]], by a *new-expression* [[expr.new]], by an operation that
6
  implicitly creates objects (see below), when implicitly changing the
7
  active member of a union [[class.union]], or when a temporary object is
8
+ created [[conv.rval]], [[class.temporary]]. An object occupies a region
9
+ of storage in its period of construction [[class.cdtor]], throughout its
10
+ lifetime [[basic.life]], and in its period of destruction
11
  [[class.cdtor]].
12
 
13
  [*Note 1*: A function is not an object, regardless of whether or not it
14
  occupies storage in the way that objects do. — *end note*]
15
 
16
  The properties of an object are determined when the object is created.
17
  An object can have a name [[basic.pre]]. An object has a storage
18
  duration [[basic.stc]] which influences its lifetime [[basic.life]]. An
19
+ object has a type [[basic.types]].
20
+
21
+ [*Note 2*: Some objects are polymorphic [[class.virtual]]; the
22
+ implementation generates information associated with each such object
23
+ that makes it possible to determine that object’s type during program
24
+ execution. *end note*]
25
 
26
  Objects can contain other objects, called *subobjects*. A subobject can
27
  be a *member subobject* [[class.mem]], a *base class subobject*
28
  [[class.derived]], or an array element. An object that is not a
29
  subobject of any other object is called a *complete object*. If an
 
41
  “array of N `std::byte`” [[cstddef.syn]], that array *provides storage*
42
  for the created object if:
43
 
44
  - the lifetime of *e* has begun and not ended, and
45
  - the storage for the new object fits entirely within *e*, and
46
+ - there is no array object that satisfies these constraints nested
47
+ within *e*.
48
 
49
+ [*Note 3*: If that portion of the array previously provided storage for
50
  another object, the lifetime of that object ends because its storage was
51
  reused [[basic.life]]. — *end note*]
52
 
53
  [*Example 1*:
54
 
 
89
  - If `x` is a complete object, then the complete object of `x` is
90
  itself.
91
  - Otherwise, the complete object of `x` is the complete object of the
92
  (unique) object that contains `x`.
93
 
94
+ If a complete object, a member subobject, or an array element is of
95
+ class type, its type is considered the *most derived class*, to
96
  distinguish it from the class type of any base class subobject; an
97
  object of a most derived class type or of a non-class type is called a
98
  *most derived object*.
99
 
100
  A *potentially-overlapping subobject* is either:
 
107
 
108
  - is not a potentially-overlapping subobject, or
109
  - is not of class type, or
110
  - is of a class type with virtual member functions or virtual base
111
  classes, or
112
+ - has subobjects of nonzero size or unnamed bit-fields of nonzero
113
+ length.
114
 
115
  Otherwise, if the object is a base class subobject of a standard-layout
116
  class type with no non-static data members, it has zero size. Otherwise,
117
  the circumstances under which the object has zero size are
118
  *implementation-defined*. Unless it is a bit-field [[class.bit]], an
119
  object with nonzero size shall occupy one or more bytes of storage,
120
  including every byte that is occupied in full or in part by any of its
121
  subobjects. An object of trivially copyable or standard-layout type
122
+ [[basic.types.general]] shall occupy contiguous bytes of storage.
123
 
124
  Unless an object is a bit-field or a subobject of zero size, the address
125
  of that object is the address of the first byte it occupies. Two objects
126
  with overlapping lifetimes that are not bit-fields may have the same
127
  address if one is nested within the other, or if at least one is a
128
  subobject of zero size and they are of different types; otherwise, they
129
+ have distinct addresses and occupy disjoint bytes of storage.[^7]
130
 
131
  [*Example 2*:
132
 
133
  ``` cpp
134
  static const char test1 = 'x';
 
144
 
145
  Some operations are described as *implicitly creating objects* within a
146
  specified region of storage. For each operation that is specified as
147
  implicitly creating objects, that operation implicitly creates and
148
  starts the lifetime of zero or more objects of implicit-lifetime types
149
+ [[basic.types.general]] in its specified region of storage if doing so
150
+ would result in the program having defined behavior. If no such set of
151
+ objects would give the program defined behavior, the behavior of the
152
+ program is undefined. If multiple such sets of objects would give the
153
+ program defined behavior, it is unspecified which such set of objects is
154
  created.
155
 
156
+ [*Note 4*: Such operations do not start the lifetimes of subobjects of
157
  such objects that are not themselves of implicit-lifetime
158
  types. — *end note*]
159
 
160
  Further, after implicitly creating objects within a specified region of
161
  storage, some operations are described as producing a pointer to a
 
186
  }
187
  ```
188
 
189
  — *end example*]
190
 
191
+ An operation that begins the lifetime of an array of `unsigned char` or
192
+ `std::byte` implicitly creates objects within the region of storage
193
+ occupied by the array.
194
 
195
+ [*Note 5*: The array object provides storage for these
196
  objects. — *end note*]
197
 
198
  Any implicit or explicit invocation of a function named `operator new`
199
  or `operator new[]` implicitly creates objects in the returned region of
200
  storage and returns a pointer to a suitable created object.
201
 
202
+ [*Note 6*: Some functions in the C++ standard library implicitly create
203
+ objects
204
+ [[obj.lifetime]], [[allocator.traits.members]], [[c.malloc]], [[cstring.syn]], [[bit.cast]]. — *end note*]
205