tmp/tmpk9wpxktl/{from.md → to.md}
RENAMED
|
@@ -41,37 +41,53 @@ class-key:
|
|
| 41 |
union
|
| 42 |
```
|
| 43 |
|
| 44 |
A class declaration where the *class-name* in the *class-head-name* is a
|
| 45 |
*simple-template-id* shall be an explicit specialization
|
| 46 |
-
[[temp.expl.spec]] or a partial specialization [[temp.
|
| 47 |
*class-specifier* whose *class-head* omits the *class-head-name* defines
|
| 48 |
an unnamed class.
|
| 49 |
|
| 50 |
[*Note 1*: An unnamed class thus can’t be `final`. — *end note*]
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
*
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
*class
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
If a *class-head-name* contains a *nested-name-specifier*, the
|
| 65 |
-
*class-specifier* shall
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
[*Note 2*: The *class-key* determines whether the class is a union
|
| 75 |
[[class.union]] and whether access is public or private by default
|
| 76 |
[[class.access]]. A union holds the value of at most one data member at
|
| 77 |
a time. — *end note*]
|
|
@@ -80,33 +96,33 @@ If a class is marked with the *class-virt-specifier* `final` and it
|
|
| 80 |
appears as a *class-or-decltype* in a *base-clause* [[class.derived]],
|
| 81 |
the program is ill-formed. Whenever a *class-key* is followed by a
|
| 82 |
*class-head-name*, the *identifier* `final`, and a colon or left brace,
|
| 83 |
`final` is interpreted as a *class-virt-specifier*.
|
| 84 |
|
| 85 |
-
[*Example
|
| 86 |
|
| 87 |
``` cpp
|
| 88 |
struct A;
|
| 89 |
-
struct A final {}; // OK
|
| 90 |
// not value-initialization of variable final
|
| 91 |
|
| 92 |
struct X {
|
| 93 |
struct C { constexpr operator int() { return 5; } };
|
| 94 |
-
struct B final : C{}; // OK
|
| 95 |
// not declaration of a bit-field member final
|
| 96 |
};
|
| 97 |
```
|
| 98 |
|
| 99 |
— *end example*]
|
| 100 |
|
| 101 |
[*Note 3*: Complete objects of class type have nonzero size. Base class
|
| 102 |
subobjects and members declared with the `no_unique_address` attribute
|
| 103 |
[[dcl.attr.nouniqueaddr]] are not so constrained. — *end note*]
|
| 104 |
|
| 105 |
-
[*Note 4*: Class objects can be assigned
|
| 106 |
-
[[class.copy.assign]]
|
| 107 |
-
[[class.copy.ctor]]
|
| 108 |
-
classes for which copying or moving has been restricted; see
|
| 109 |
[[dcl.fct.def.delete]] and [[class.access]]). Other plausible operators,
|
| 110 |
such as equality comparison, can be defined by the user; see
|
| 111 |
[[over.oper]]. — *end note*]
|
| 112 |
|
|
|
|
| 41 |
union
|
| 42 |
```
|
| 43 |
|
| 44 |
A class declaration where the *class-name* in the *class-head-name* is a
|
| 45 |
*simple-template-id* shall be an explicit specialization
|
| 46 |
+
[[temp.expl.spec]] or a partial specialization [[temp.spec.partial]]. A
|
| 47 |
*class-specifier* whose *class-head* omits the *class-head-name* defines
|
| 48 |
an unnamed class.
|
| 49 |
|
| 50 |
[*Note 1*: An unnamed class thus can’t be `final`. — *end note*]
|
| 51 |
|
| 52 |
+
Otherwise, the *class-name* is an *identifier*; it is not looked up, and
|
| 53 |
+
the *class-specifier* introduces it.
|
| 54 |
+
|
| 55 |
+
The *class-name* is also bound in the scope of the class (template)
|
| 56 |
+
itself; this is known as the *injected-class-name*. For purposes of
|
| 57 |
+
access checking, the injected-class-name is treated as if it were a
|
| 58 |
+
public member name. A *class-specifier* is commonly referred to as a
|
| 59 |
+
*class definition*. A class is considered defined after the closing
|
| 60 |
+
brace of its *class-specifier* has been seen even though its member
|
| 61 |
+
functions are in general not yet defined. The optional
|
| 62 |
+
*attribute-specifier-seq* appertains to the class; the attributes in the
|
| 63 |
+
*attribute-specifier-seq* are thereafter considered attributes of the
|
| 64 |
+
class whenever it is named.
|
| 65 |
|
| 66 |
If a *class-head-name* contains a *nested-name-specifier*, the
|
| 67 |
+
*class-specifier* shall not inhabit a class scope. If its *class-name*
|
| 68 |
+
is an *identifier*, the *class-specifier* shall correspond to one or
|
| 69 |
+
more declarations nominable in the class, class template, or namespace
|
| 70 |
+
to which the *nested-name-specifier* refers; they shall all have the
|
| 71 |
+
same target scope, and the target scope of the *class-specifier* is that
|
| 72 |
+
scope.
|
| 73 |
+
|
| 74 |
+
[*Example 1*:
|
| 75 |
+
|
| 76 |
+
``` cpp
|
| 77 |
+
namespace N {
|
| 78 |
+
template<class>
|
| 79 |
+
struct A {
|
| 80 |
+
struct B;
|
| 81 |
+
};
|
| 82 |
+
}
|
| 83 |
+
using N::A;
|
| 84 |
+
template<class T> struct A<T>::B {}; // OK
|
| 85 |
+
template<> struct A<void> {}; // OK
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
— *end example*]
|
| 89 |
|
| 90 |
[*Note 2*: The *class-key* determines whether the class is a union
|
| 91 |
[[class.union]] and whether access is public or private by default
|
| 92 |
[[class.access]]. A union holds the value of at most one data member at
|
| 93 |
a time. — *end note*]
|
|
|
|
| 96 |
appears as a *class-or-decltype* in a *base-clause* [[class.derived]],
|
| 97 |
the program is ill-formed. Whenever a *class-key* is followed by a
|
| 98 |
*class-head-name*, the *identifier* `final`, and a colon or left brace,
|
| 99 |
`final` is interpreted as a *class-virt-specifier*.
|
| 100 |
|
| 101 |
+
[*Example 2*:
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
struct A;
|
| 105 |
+
struct A final {}; // OK, definition of struct A,
|
| 106 |
// not value-initialization of variable final
|
| 107 |
|
| 108 |
struct X {
|
| 109 |
struct C { constexpr operator int() { return 5; } };
|
| 110 |
+
struct B final : C{}; // OK, definition of nested class B,
|
| 111 |
// not declaration of a bit-field member final
|
| 112 |
};
|
| 113 |
```
|
| 114 |
|
| 115 |
— *end example*]
|
| 116 |
|
| 117 |
[*Note 3*: Complete objects of class type have nonzero size. Base class
|
| 118 |
subobjects and members declared with the `no_unique_address` attribute
|
| 119 |
[[dcl.attr.nouniqueaddr]] are not so constrained. — *end note*]
|
| 120 |
|
| 121 |
+
[*Note 4*: Class objects can be assigned
|
| 122 |
+
[[over.ass]], [[class.copy.assign]], passed as arguments to functions
|
| 123 |
+
[[dcl.init]], [[class.copy.ctor]], and returned by functions (except
|
| 124 |
+
objects of classes for which copying or moving has been restricted; see
|
| 125 |
[[dcl.fct.def.delete]] and [[class.access]]). Other plausible operators,
|
| 126 |
such as equality comparison, can be defined by the user; see
|
| 127 |
[[over.oper]]. — *end note*]
|
| 128 |
|