From Jason Turner

[temp.dep.type]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgau1vai1/{from.md → to.md} +49 -36
tmp/tmpgau1vai1/{from.md → to.md} RENAMED
@@ -2,41 +2,50 @@
2
 
3
  A name refers to the *current instantiation* if it is
4
 
5
  - in the definition of a class template, a nested class of a class
6
  template, a member of a class template, or a member of a nested class
7
- of a class template, the injected-class-name (Clause  [[class]]) of
8
- the class template or nested class,
9
  - in the definition of a primary class template or a member of a primary
10
  class template, the name of the class template followed by the
11
  template argument list of the primary template (as described below)
12
  enclosed in `<>` (or an equivalent template alias specialization),
13
  - in the definition of a nested class of a class template, the name of
14
  the nested class referenced as a member of the current instantiation,
15
  or
16
  - in the definition of a partial specialization or a member of a partial
17
  specialization, the name of the class template followed by the
18
  template argument list of the partial specialization enclosed in `<>`
19
- (or an equivalent template alias specialization). If the *n*th
20
- template parameter is a parameter pack, the *n*th template argument is
21
- a pack expansion ([[temp.variadic]]) whose pattern is the name of the
22
- parameter pack.
23
 
24
  The template argument list of a primary template is a template argument
25
- list in which the *n*th template argument has the value of the *n*th
26
- template parameter of the class template. If the *n*th template
27
- parameter is a template parameter pack ([[temp.variadic]]), the *n*th
28
- template argument is a pack expansion ([[temp.variadic]]) whose pattern
29
- is the name of the template parameter pack.
30
 
31
- A template argument that is equivalent to a template parameter (i.e.,
32
- has the same constant value or the same type as the template parameter)
33
- can be used in place of that template parameter in a reference to the
34
- current instantiation. In the case of a non-type template argument, the
35
- argument must have been given the value of the template parameter and
36
- not an expression in which the template parameter appears as a
37
- subexpression.
 
 
 
 
 
 
 
 
 
38
 
39
  [*Example 1*:
40
 
41
  ``` cpp
42
  template <class T> class A {
@@ -61,22 +70,26 @@ template <class T1, class T2, int I> struct B {
61
  B<T2, T1, I>* b2; // not the current instantiation
62
  typedef T1 my_T1;
63
  static const int my_I = I;
64
  static const int my_I2 = I+0;
65
  static const int my_I3 = my_I;
 
 
66
  B<my_T1, T2, my_I>* b3; // refers to the current instantiation
67
  B<my_T1, T2, my_I2>* b4; // not the current instantiation
68
  B<my_T1, T2, my_I3>* b5; // refers to the current instantiation
 
 
69
  };
70
  ```
71
 
72
  — *end example*]
73
 
74
  A *dependent base class* is a base class that is a dependent type and is
75
  not the current instantiation.
76
 
77
- [*Note 1*:
78
 
79
  A base class can be the current instantiation in the case of a nested
80
  class naming an enclosing class as a base.
81
 
82
  [*Example 2*:
@@ -101,26 +114,26 @@ template<class T> struct A<T>::B::C : A<T> {
101
 
102
  A name is a *member of the current instantiation* if it is
103
 
104
  - An unqualified name that, when looked up, refers to at least one
105
  member of a class that is the current instantiation or a non-dependent
106
- base class thereof. \[*Note 2*: This can only occur when looking up a
107
  name in a scope enclosed by the definition of a class
108
  template. — *end note*]
109
  - A *qualified-id* in which the *nested-name-specifier* refers to the
110
  current instantiation and that, when looked up, refers to at least one
111
  member of a class that is the current instantiation or a non-dependent
112
- base class thereof. \[*Note 3*: If no such member is found, and the
113
  current instantiation has any dependent base classes, then the
114
  *qualified-id* is a member of an unknown specialization; see
115
  below. — *end note*]
116
  - An *id-expression* denoting the member in a class member access
117
- expression ([[expr.ref]]) for which the type of the object expression
118
- is the current instantiation, and the *id-expression*, when looked
119
- up ([[basic.lookup.classref]]), refers to at least one member of a
120
- class that is the current instantiation or a non-dependent base class
121
- thereof. \[*Note 4*: If no such member is found, and the current
122
  instantiation has any dependent base classes, then the *id-expression*
123
  is a member of an unknown specialization; see below. — *end note*]
124
 
125
  [*Example 3*:
126
 
@@ -152,18 +165,18 @@ A name is a *member of an unknown specialization* if it is
152
  current instantiation, the current instantiation has at least one
153
  dependent base class, and name lookup of the *qualified-id* does not
154
  find any member of a class that is the current instantiation or a
155
  non-dependent base class thereof.
156
  - An *id-expression* denoting the member in a class member access
157
- expression ([[expr.ref]]) in which either
158
  - the type of the object expression is the current instantiation, the
159
  current instantiation has at least one dependent base class, and
160
  name lookup of the *id-expression* does not find a member of a class
161
  that is the current instantiation or a non-dependent base class
162
  thereof; or
163
- - the type of the object expression is dependent and is not the
164
- current instantiation.
165
 
166
  If a *qualified-id* in which the *nested-name-specifier* refers to the
167
  current instantiation is not a member of the current instantiation or a
168
  member of an unknown specialization, the program is ill-formed even if
169
  the template containing the *qualified-id* is not instantiated; no
@@ -230,19 +243,19 @@ A type is dependent if it is
230
  - a cv-qualified type where the cv-unqualified type is dependent,
231
  - a compound type constructed from any dependent type,
232
  - an array type whose element type is dependent or whose bound (if any)
233
  is value-dependent,
234
  - a function type whose exception specification is value-dependent,
235
- - a *simple-template-id* in which either the template name is a template
236
- parameter or any of the template arguments is a dependent type or an
237
- expression that is type-dependent or value-dependent or is a pack
238
- expansion \[*Note 5*: This includes an injected-class-name (Clause
239
- [[class]]) of a class template used without a
240
  *template-argument-list*. — *end note*] , or
241
  - denoted by `decltype(`*expression*`)`, where *expression* is
242
- type-dependent ([[temp.dep.expr]]).
243
 
244
- [*Note 6*: Because typedefs do not introduce new types, but instead
245
  simply refer to other types, a name that refers to a typedef that is a
246
  member of the current instantiation is dependent only if the type
247
  referred to is dependent. — *end note*]
248
 
 
2
 
3
  A name refers to the *current instantiation* if it is
4
 
5
  - in the definition of a class template, a nested class of a class
6
  template, a member of a class template, or a member of a nested class
7
+ of a class template, the injected-class-name [[class.pre]] of the
8
+ class template or nested class,
9
  - in the definition of a primary class template or a member of a primary
10
  class template, the name of the class template followed by the
11
  template argument list of the primary template (as described below)
12
  enclosed in `<>` (or an equivalent template alias specialization),
13
  - in the definition of a nested class of a class template, the name of
14
  the nested class referenced as a member of the current instantiation,
15
  or
16
  - in the definition of a partial specialization or a member of a partial
17
  specialization, the name of the class template followed by the
18
  template argument list of the partial specialization enclosed in `<>`
19
+ (or an equivalent template alias specialization). If the nᵗʰ template
20
+ parameter is a template parameter pack, the nᵗʰ template argument is a
21
+ pack expansion [[temp.variadic]] whose pattern is the name of the
22
+ template parameter pack.
23
 
24
  The template argument list of a primary template is a template argument
25
+ list in which the nᵗʰ template argument has the value of the nᵗʰ
26
+ template parameter of the class template. If the nᵗʰ template parameter
27
+ is a template parameter pack [[temp.variadic]], the nᵗʰ template
28
+ argument is a pack expansion [[temp.variadic]] whose pattern is the name
29
+ of the template parameter pack.
30
 
31
+ A template argument that is equivalent to a template parameter can be
32
+ used in place of that template parameter in a reference to the current
33
+ instantiation. For a template *type-parameter*, a template argument is
34
+ equivalent to a template parameter if it denotes the same type. For a
35
+ non-type template parameter, a template argument is equivalent to a
36
+ template parameter if it is an *identifier* that names a variable that
37
+ is equivalent to the template parameter. A variable is equivalent to a
38
+ template parameter if
39
+
40
+ - it has the same type as the template parameter (ignoring
41
+ cv-qualification) and
42
+ - its initializer consists of a single *identifier* that names the
43
+ template parameter or, recursively, such a variable.
44
+
45
+ [*Note 1*: Using a parenthesized variable name breaks the
46
+ equivalence. — *end note*]
47
 
48
  [*Example 1*:
49
 
50
  ``` cpp
51
  template <class T> class A {
 
70
  B<T2, T1, I>* b2; // not the current instantiation
71
  typedef T1 my_T1;
72
  static const int my_I = I;
73
  static const int my_I2 = I+0;
74
  static const int my_I3 = my_I;
75
+ static const long my_I4 = I;
76
+ static const int my_I5 = (I);
77
  B<my_T1, T2, my_I>* b3; // refers to the current instantiation
78
  B<my_T1, T2, my_I2>* b4; // not the current instantiation
79
  B<my_T1, T2, my_I3>* b5; // refers to the current instantiation
80
+ B<my_T1, T2, my_I4>* b6; // not the current instantiation
81
+ B<my_T1, T2, my_I5>* b7; // not the current instantiation
82
  };
83
  ```
84
 
85
  — *end example*]
86
 
87
  A *dependent base class* is a base class that is a dependent type and is
88
  not the current instantiation.
89
 
90
+ [*Note 2*:
91
 
92
  A base class can be the current instantiation in the case of a nested
93
  class naming an enclosing class as a base.
94
 
95
  [*Example 2*:
 
114
 
115
  A name is a *member of the current instantiation* if it is
116
 
117
  - An unqualified name that, when looked up, refers to at least one
118
  member of a class that is the current instantiation or a non-dependent
119
+ base class thereof. \[*Note 3*: This can only occur when looking up a
120
  name in a scope enclosed by the definition of a class
121
  template. — *end note*]
122
  - A *qualified-id* in which the *nested-name-specifier* refers to the
123
  current instantiation and that, when looked up, refers to at least one
124
  member of a class that is the current instantiation or a non-dependent
125
+ base class thereof. \[*Note 4*: If no such member is found, and the
126
  current instantiation has any dependent base classes, then the
127
  *qualified-id* is a member of an unknown specialization; see
128
  below. — *end note*]
129
  - An *id-expression* denoting the member in a class member access
130
+ expression [[expr.ref]] for which the type of the object expression is
131
+ the current instantiation, and the *id-expression*, when looked up
132
+ [[basic.lookup.classref]], refers to at least one member of a class
133
+ that is the current instantiation or a non-dependent base class
134
+ thereof. \[*Note 5*: If no such member is found, and the current
135
  instantiation has any dependent base classes, then the *id-expression*
136
  is a member of an unknown specialization; see below. — *end note*]
137
 
138
  [*Example 3*:
139
 
 
165
  current instantiation, the current instantiation has at least one
166
  dependent base class, and name lookup of the *qualified-id* does not
167
  find any member of a class that is the current instantiation or a
168
  non-dependent base class thereof.
169
  - An *id-expression* denoting the member in a class member access
170
+ expression [[expr.ref]] in which either
171
  - the type of the object expression is the current instantiation, the
172
  current instantiation has at least one dependent base class, and
173
  name lookup of the *id-expression* does not find a member of a class
174
  that is the current instantiation or a non-dependent base class
175
  thereof; or
176
+ - the type of the object expression is not the current instantiation
177
+ and the object expression is type-dependent.
178
 
179
  If a *qualified-id* in which the *nested-name-specifier* refers to the
180
  current instantiation is not a member of the current instantiation or a
181
  member of an unknown specialization, the program is ill-formed even if
182
  the template containing the *qualified-id* is not instantiated; no
 
243
  - a cv-qualified type where the cv-unqualified type is dependent,
244
  - a compound type constructed from any dependent type,
245
  - an array type whose element type is dependent or whose bound (if any)
246
  is value-dependent,
247
  - a function type whose exception specification is value-dependent,
248
+ - denoted by a *simple-template-id* in which either the template name is
249
+ a template parameter or any of the template arguments is a dependent
250
+ type or an expression that is type-dependent or value-dependent or is
251
+ a pack expansion \[*Note 6*: This includes an injected-class-name
252
+ [[class.pre]] of a class template used without a
253
  *template-argument-list*. — *end note*] , or
254
  - denoted by `decltype(`*expression*`)`, where *expression* is
255
+ type-dependent [[temp.dep.expr]].
256
 
257
+ [*Note 7*: Because typedefs do not introduce new types, but instead
258
  simply refer to other types, a name that refers to a typedef that is a
259
  member of the current instantiation is dependent only if the type
260
  referred to is dependent. — *end note*]
261