From Jason Turner

[dcl.type.elab]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpga756gt_/{from.md → to.md} +32 -25
tmp/tmpga756gt_/{from.md → to.md} RENAMED
@@ -2,73 +2,80 @@
2
 
3
  ``` bnf
4
  elaborated-type-specifier:
5
  class-key attribute-specifier-seqₒₚₜ nested-name-specifierₒₚₜ identifier
6
  class-key simple-template-id
7
- class-key nested-name-specifier 'template'ₒₚₜ simple-template-id
8
- 'enum' nested-name-specifierₒₚₜ identifier
 
 
 
 
 
9
  ```
10
 
11
  An *attribute-specifier-seq* shall not appear in an
12
  *elaborated-type-specifier* unless the latter is the sole constituent of
13
  a declaration. If an *elaborated-type-specifier* is the sole constituent
14
  of a declaration, the declaration is ill-formed unless it is an explicit
15
- specialization ([[temp.expl.spec]]), an explicit instantiation (
16
- [[temp.explicit]]) or it has one of the following forms:
17
 
18
  ``` bnf
19
  class-key attribute-specifier-seqₒₚₜ identifier ';'
20
- 'friend' class-key '::'ₒₚₜ identifier ';'
21
- 'friend' class-key '::'ₒₚₜ simple-template-id ';'
22
- 'friend' class-key nested-name-specifier identifier ';'
23
- 'friend' class-key nested-name-specifier 'template'ₒₚₜ simple-template-id ';'
24
  ```
25
 
26
  In the first case, the *attribute-specifier-seq*, if any, appertains to
27
  the class being declared; the attributes in the
28
  *attribute-specifier-seq* are thereafter considered attributes of the
29
  class whenever it is named.
30
 
31
- [[basic.lookup.elab]] describes how name lookup proceeds for the
32
- *identifier* in an *elaborated-type-specifier*. If the *identifier*
33
- resolves to a *class-name* or *enum-name*, the
34
- *elaborated-type-specifier* introduces it into the declaration the same
35
- way a *simple-type-specifier* introduces its *type-name*. If the
36
- *identifier* resolves to a *typedef-name* or the *simple-template-id*
37
- resolves to an alias template specialization, the
38
- *elaborated-type-specifier* is ill-formed.
39
 
40
- [*Note 1*:
 
 
 
 
 
 
 
41
 
42
  This implies that, within a class template with a template
43
  *type-parameter* `T`, the declaration
44
 
45
  ``` cpp
46
  friend class T;
47
  ```
48
 
49
- is ill-formed. However, the similar declaration `friend T;` is allowed (
50
- [[class.friend]]).
51
 
52
  — *end note*]
53
 
54
  The *class-key* or `enum` keyword present in the
55
  *elaborated-type-specifier* shall agree in kind with the declaration to
56
  which the name in the *elaborated-type-specifier* refers. This rule also
57
  applies to the form of *elaborated-type-specifier* that declares a
58
- *class-name* or `friend` class since it can be construed as referring to
59
  the definition of the class. Thus, in any *elaborated-type-specifier*,
60
- the `enum` keyword shall be used to refer to an enumeration (
61
- [[dcl.enum]]), the `union` *class-key* shall be used to refer to a union
62
- (Clause  [[class]]), and either the `class` or `struct` *class-key*
63
- shall be used to refer to a class (Clause  [[class]]) declared using the
64
- `class` or `struct` *class-key*.
65
 
66
  [*Example 1*:
67
 
68
  ``` cpp
69
  enum class E { a, b };
70
  enum E x = E::a; // OK
 
 
71
  ```
72
 
73
  — *end example*]
74
 
 
2
 
3
  ``` bnf
4
  elaborated-type-specifier:
5
  class-key attribute-specifier-seqₒₚₜ nested-name-specifierₒₚₜ identifier
6
  class-key simple-template-id
7
+ class-key nested-name-specifier templateₒₚₜ simple-template-id
8
+ elaborated-enum-specifier
9
+ ```
10
+
11
+ ``` bnf
12
+ elaborated-enum-specifier:
13
+ enum nested-name-specifierₒₚₜ identifier
14
  ```
15
 
16
  An *attribute-specifier-seq* shall not appear in an
17
  *elaborated-type-specifier* unless the latter is the sole constituent of
18
  a declaration. If an *elaborated-type-specifier* is the sole constituent
19
  of a declaration, the declaration is ill-formed unless it is an explicit
20
+ specialization [[temp.expl.spec]], an explicit instantiation
21
+ [[temp.explicit]] or it has one of the following forms:
22
 
23
  ``` bnf
24
  class-key attribute-specifier-seqₒₚₜ identifier ';'
25
+ friend class-key '::ₒₚₜ ' identifier ';'
26
+ friend class-key '::ₒₚₜ ' simple-template-id ';'
27
+ friend class-key nested-name-specifier identifier ';'
28
+ friend class-key nested-name-specifier templateₒₚₜ simple-template-id ';'
29
  ```
30
 
31
  In the first case, the *attribute-specifier-seq*, if any, appertains to
32
  the class being declared; the attributes in the
33
  *attribute-specifier-seq* are thereafter considered attributes of the
34
  class whenever it is named.
35
 
36
+ [*Note 1*: [[basic.lookup.elab]] describes how name lookup proceeds
37
+ for the *identifier* in an *elaborated-type-specifier*. *end note*]
 
 
 
 
 
 
38
 
39
+ If the *identifier* or *simple-template-id* resolves to a *class-name*
40
+ or *enum-name*, the *elaborated-type-specifier* introduces it into the
41
+ declaration the same way a *simple-type-specifier* introduces its
42
+ *type-name* [[dcl.type.simple]]. If the *identifier* or
43
+ *simple-template-id* resolves to a *typedef-name* ([[dcl.typedef]],
44
+ [[temp.names]]), the *elaborated-type-specifier* is ill-formed.
45
+
46
+ [*Note 2*:
47
 
48
  This implies that, within a class template with a template
49
  *type-parameter* `T`, the declaration
50
 
51
  ``` cpp
52
  friend class T;
53
  ```
54
 
55
+ is ill-formed. However, the similar declaration `friend T;` is allowed
56
+ [[class.friend]].
57
 
58
  — *end note*]
59
 
60
  The *class-key* or `enum` keyword present in the
61
  *elaborated-type-specifier* shall agree in kind with the declaration to
62
  which the name in the *elaborated-type-specifier* refers. This rule also
63
  applies to the form of *elaborated-type-specifier* that declares a
64
+ *class-name* or friend class since it can be construed as referring to
65
  the definition of the class. Thus, in any *elaborated-type-specifier*,
66
+ the `enum` keyword shall be used to refer to an enumeration
67
+ [[dcl.enum]], the `union` *class-key* shall be used to refer to a union
68
+ [[class.union]], and either the `class` or `struct` *class-key* shall be
69
+ used to refer to a non-union class [[class.pre]].
 
70
 
71
  [*Example 1*:
72
 
73
  ``` cpp
74
  enum class E { a, b };
75
  enum E x = E::a; // OK
76
+ struct S { } s;
77
+ class S* p = &s; // OK
78
  ```
79
 
80
  — *end example*]
81