tmp/tmpkziqa58r/{from.md → to.md}
RENAMED
|
@@ -10,11 +10,11 @@ ctor-initializer:
|
|
| 10 |
```
|
| 11 |
|
| 12 |
``` bnf
|
| 13 |
mem-initializer-list:
|
| 14 |
mem-initializer '...'ₒₚₜ
|
| 15 |
-
mem-initializer ',' mem-initializer-list
|
| 16 |
```
|
| 17 |
|
| 18 |
``` bnf
|
| 19 |
mem-initializer:
|
| 20 |
mem-initializer-id '(' expression-listₒₚₜ ')'
|
|
@@ -112,31 +112,39 @@ full-expression. Any expression in a *mem-initializer* is evaluated as
|
|
| 112 |
part of the full-expression that performs the initialization. A
|
| 113 |
*mem-initializer* where the *mem-initializer-id* denotes a virtual base
|
| 114 |
class is ignored during execution of a constructor of any class that is
|
| 115 |
not the most derived class.
|
| 116 |
|
| 117 |
-
In a non-delegating constructor, if a given
|
| 118 |
-
|
| 119 |
case where there is no *mem-initializer-list* because the constructor
|
| 120 |
-
has no *ctor-initializer*)
|
| 121 |
-
an abstract class ([[class.abstract]]), then
|
| 122 |
|
| 123 |
- if the entity is a non-static data member that has a
|
| 124 |
-
*brace-or-equal-initializer*
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
- otherwise, the entity is default-initialized ([[dcl.init]]).
|
| 129 |
|
| 130 |
An abstract class ([[class.abstract]]) is never a most derived class,
|
| 131 |
thus its constructors never initialize virtual base classes, therefore
|
| 132 |
the corresponding *mem-initializer*s may be omitted. An attempt to
|
| 133 |
initialize more than one non-static data member of a union renders the
|
| 134 |
-
program ill-formed. After the call to a constructor for class `X`
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
| 138 |
|
| 139 |
``` cpp
|
| 140 |
struct A {
|
| 141 |
A();
|
| 142 |
};
|
|
@@ -169,10 +177,16 @@ struct A {
|
|
| 169 |
|
| 170 |
the `A(int)` constructor will simply initialize `i` to the value of
|
| 171 |
`arg`, and the side effects in `i`’s *brace-or-equal-initializer* will
|
| 172 |
not take place.
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
In a non-delegating constructor, initialization proceeds in the
|
| 175 |
following order:
|
| 176 |
|
| 177 |
- First, and only for the constructor of the most derived class (
|
| 178 |
[[intro.object]]), virtual base classes are initialized in the order
|
|
|
|
| 10 |
```
|
| 11 |
|
| 12 |
``` bnf
|
| 13 |
mem-initializer-list:
|
| 14 |
mem-initializer '...'ₒₚₜ
|
| 15 |
+
mem-initializer '...'ₒₚₜ ',' mem-initializer-list
|
| 16 |
```
|
| 17 |
|
| 18 |
``` bnf
|
| 19 |
mem-initializer:
|
| 20 |
mem-initializer-id '(' expression-listₒₚₜ ')'
|
|
|
|
| 112 |
part of the full-expression that performs the initialization. A
|
| 113 |
*mem-initializer* where the *mem-initializer-id* denotes a virtual base
|
| 114 |
class is ignored during execution of a constructor of any class that is
|
| 115 |
not the most derived class.
|
| 116 |
|
| 117 |
+
In a non-delegating constructor, if a given potentially constructed
|
| 118 |
+
subobject is not designated by a *mem-initializer-id* (including the
|
| 119 |
case where there is no *mem-initializer-list* because the constructor
|
| 120 |
+
has no *ctor-initializer*), then
|
|
|
|
| 121 |
|
| 122 |
- if the entity is a non-static data member that has a
|
| 123 |
+
*brace-or-equal-initializer* and either
|
| 124 |
+
- the constructor’s class is a union ([[class.union]]), and no other
|
| 125 |
+
variant member of that union is designated by a *mem-initializer-id*
|
| 126 |
+
or
|
| 127 |
+
- the constructor’s class is not a union, and, if the entity is a
|
| 128 |
+
member of an anonymous union, no other member of that union is
|
| 129 |
+
designated by a *mem-initializer-id*,
|
| 130 |
+
|
| 131 |
+
the entity is initialized as specified in [[dcl.init]];
|
| 132 |
+
- otherwise, if the entity is an anonymous union or a variant member (
|
| 133 |
+
[[class.union]]), no initialization is performed;
|
| 134 |
- otherwise, the entity is default-initialized ([[dcl.init]]).
|
| 135 |
|
| 136 |
An abstract class ([[class.abstract]]) is never a most derived class,
|
| 137 |
thus its constructors never initialize virtual base classes, therefore
|
| 138 |
the corresponding *mem-initializer*s may be omitted. An attempt to
|
| 139 |
initialize more than one non-static data member of a union renders the
|
| 140 |
+
program ill-formed. After the call to a constructor for class `X` for an
|
| 141 |
+
object with automatic or dynamic storage duration has completed, if the
|
| 142 |
+
constructor was not invoked as part of value-initialization and a member
|
| 143 |
+
of `X` is neither initialized nor given a value during execution of the
|
| 144 |
+
*compound-statement* of the body of the constructor, the member has an
|
| 145 |
+
indeterminate value.
|
| 146 |
|
| 147 |
``` cpp
|
| 148 |
struct A {
|
| 149 |
A();
|
| 150 |
};
|
|
|
|
| 177 |
|
| 178 |
the `A(int)` constructor will simply initialize `i` to the value of
|
| 179 |
`arg`, and the side effects in `i`’s *brace-or-equal-initializer* will
|
| 180 |
not take place.
|
| 181 |
|
| 182 |
+
In a non-delegating constructor, the destructor for each potentially
|
| 183 |
+
constructed subobject of class type is potentially invoked (
|
| 184 |
+
[[class.dtor]]). This provision ensures that destructors can be called
|
| 185 |
+
for fully-constructed sub-objects in case an exception is thrown (
|
| 186 |
+
[[except.ctor]]).
|
| 187 |
+
|
| 188 |
In a non-delegating constructor, initialization proceeds in the
|
| 189 |
following order:
|
| 190 |
|
| 191 |
- First, and only for the constructor of the most derived class (
|
| 192 |
[[intro.object]]), virtual base classes are initialized in the order
|