tmp/tmpr85n_v21/{from.md → to.md}
RENAMED
|
@@ -3,15 +3,19 @@
|
|
| 3 |
When a constructor for type `B` is invoked to initialize an object of a
|
| 4 |
different type `D` (that is, when the constructor was inherited
|
| 5 |
[[namespace.udecl]]), initialization proceeds as if a defaulted default
|
| 6 |
constructor were used to initialize the `D` object and each base class
|
| 7 |
subobject from which the constructor was inherited, except that the `B`
|
| 8 |
-
subobject is initialized by the
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
object.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
[*Example 1*:
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
struct B1 {
|
|
@@ -60,14 +64,33 @@ Class template `Log` wraps any class and forwards all of its
|
|
| 60 |
constructors, while writing a message to the standard log whenever an
|
| 61 |
object of class `Log` is destroyed.
|
| 62 |
|
| 63 |
— *end example*]
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
If the constructor was inherited from multiple base class subobjects of
|
| 66 |
type `B`, the program is ill-formed.
|
| 67 |
|
| 68 |
-
[*Example
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
struct A { A(int); };
|
| 72 |
struct B : A { using A::A; };
|
| 73 |
|
|
|
|
| 3 |
When a constructor for type `B` is invoked to initialize an object of a
|
| 4 |
different type `D` (that is, when the constructor was inherited
|
| 5 |
[[namespace.udecl]]), initialization proceeds as if a defaulted default
|
| 6 |
constructor were used to initialize the `D` object and each base class
|
| 7 |
subobject from which the constructor was inherited, except that the `B`
|
| 8 |
+
subobject is initialized by the inherited constructor if the base class
|
| 9 |
+
subobject were to be initialized as part of the `D` object
|
| 10 |
+
[[class.base.init]]. The invocation of the inherited constructor,
|
| 11 |
+
including the evaluation of any arguments, is omitted if the `B`
|
| 12 |
+
subobject is not to be initialized as part of the `D` object. The
|
| 13 |
+
complete initialization is considered to be a single function call; in
|
| 14 |
+
particular, unless omitted, the initialization of the inherited
|
| 15 |
+
constructor’s parameters is sequenced before the initialization of any
|
| 16 |
+
part of the `D` object.
|
| 17 |
|
| 18 |
[*Example 1*:
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
struct B1 {
|
|
|
|
| 64 |
constructors, while writing a message to the standard log whenever an
|
| 65 |
object of class `Log` is destroyed.
|
| 66 |
|
| 67 |
— *end example*]
|
| 68 |
|
| 69 |
+
[*Example 2*:
|
| 70 |
+
|
| 71 |
+
``` cpp
|
| 72 |
+
struct V { V() = default; V(int); };
|
| 73 |
+
struct Q { Q(); };
|
| 74 |
+
struct A : virtual V, Q {
|
| 75 |
+
using V::V;
|
| 76 |
+
A() = delete;
|
| 77 |
+
};
|
| 78 |
+
int bar() { return 42; }
|
| 79 |
+
struct B : A {
|
| 80 |
+
B() : A(bar()) {} // OK
|
| 81 |
+
};
|
| 82 |
+
struct C : B {};
|
| 83 |
+
void foo() { C c; } // bar is not invoked, because the V subobject is not initialized as part of B
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
— *end example*]
|
| 87 |
+
|
| 88 |
If the constructor was inherited from multiple base class subobjects of
|
| 89 |
type `B`, the program is ill-formed.
|
| 90 |
|
| 91 |
+
[*Example 3*:
|
| 92 |
|
| 93 |
``` cpp
|
| 94 |
struct A { A(int); };
|
| 95 |
struct B : A { using A::A; };
|
| 96 |
|