From Jason Turner

[class.pre]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvqg9q5so/{from.md → to.md} +112 -0
tmp/tmpvqg9q5so/{from.md → to.md} RENAMED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Preamble <a id="class.pre">[[class.pre]]</a>
2
+
3
+ A class is a type. Its name becomes a *class-name* [[class.name]] within
4
+ its scope.
5
+
6
+ ``` bnf
7
+ class-name:
8
+ identifier
9
+ simple-template-id
10
+ ```
11
+
12
+ A *class-specifier* or an *elaborated-type-specifier* [[dcl.type.elab]]
13
+ is used to make a *class-name*. An object of a class consists of a
14
+ (possibly empty) sequence of members and base class objects.
15
+
16
+ ``` bnf
17
+ class-specifier:
18
+ class-head '{' member-specificationₒₚₜ '}'
19
+ ```
20
+
21
+ ``` bnf
22
+ class-head:
23
+ class-key attribute-specifier-seqₒₚₜ class-head-name class-virt-specifierₒₚₜ base-clauseₒₚₜ
24
+ class-key attribute-specifier-seqₒₚₜ base-clauseₒₚₜ
25
+ ```
26
+
27
+ ``` bnf
28
+ class-head-name:
29
+ nested-name-specifierₒₚₜ class-name
30
+ ```
31
+
32
+ ``` bnf
33
+ class-virt-specifier:
34
+ final
35
+ ```
36
+
37
+ ``` bnf
38
+ class-key:
39
+ class
40
+ struct
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.class.spec]]. 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
+ A *class-name* is inserted into the scope in which it is declared
53
+ immediately after the *class-name* is seen. The *class-name* is also
54
+ inserted into the scope of the class itself; this is known as the
55
+ *injected-class-name*. For purposes of access checking, the
56
+ injected-class-name is treated as if it were a public member name. A
57
+ *class-specifier* is commonly referred to as a *class definition*. A
58
+ class is considered defined after the closing brace of its
59
+ *class-specifier* has been seen even though its member functions are in
60
+ general not yet defined. The optional *attribute-specifier-seq*
61
+ appertains to the class; the attributes in the *attribute-specifier-seq*
62
+ are thereafter considered attributes of the class whenever it is named.
63
+
64
+ If a *class-head-name* contains a *nested-name-specifier*, the
65
+ *class-specifier* shall refer to a class that was previously declared
66
+ directly in the class or namespace to which the *nested-name-specifier*
67
+ refers, or in an element of the inline namespace set [[namespace.def]]
68
+ of that namespace (i.e., not merely inherited or introduced by a
69
+ *using-declaration*), and the *class-specifier* shall appear in a
70
+ namespace enclosing the previous declaration. In such cases, the
71
+ *nested-name-specifier* of the *class-head-name* of the definition shall
72
+ not begin with a *decltype-specifier*.
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*]
78
+
79
+ 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 1*:
86
+
87
+ ``` cpp
88
+ struct A;
89
+ struct A final {}; // OK: definition of struct A,
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: definition of nested class B,
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 ([[over.ass]],
106
+ [[class.copy.assign]]), passed as arguments to functions ([[dcl.init]],
107
+ [[class.copy.ctor]]), and returned by functions (except objects of
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
+