From Jason Turner

[class.pre]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpk9wpxktl/{from.md → to.md} +43 -27
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.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*]
@@ -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 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
 
 
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