From Jason Turner

[temp.param]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_d8pbntc/{from.md → to.md} +21 -28
tmp/tmp_d8pbntc/{from.md → to.md} RENAMED
@@ -28,20 +28,24 @@ type-parameter-key:
28
  type-constraint:
29
  nested-name-specifierₒₚₜ concept-name
30
  nested-name-specifierₒₚₜ concept-name '<' template-argument-listₒₚₜ '>'
31
  ```
32
 
 
 
 
33
  [*Note 1*: The `>` token following the *template-parameter-list* of a
34
- *type-parameter* may be the product of replacing a `>{>}` token by two
35
  consecutive `>` tokens [[temp.names]]. — *end note*]
36
 
37
  There is no semantic difference between `class` and `typename` in a
38
  *type-parameter-key*. `typename` followed by an *unqualified-id* names a
39
  template type parameter. `typename` followed by a *qualified-id* denotes
40
- the type in a non-type [^1] *parameter-declaration*. A
41
- *template-parameter* of the form `class` *identifier* is a
42
- *type-parameter*.
 
43
 
44
  [*Example 1*:
45
 
46
  ``` cpp
47
  class T { ... };
@@ -60,18 +64,19 @@ unnamed non-type *template-parameter* of class `T`.
60
 
61
  A storage class shall not be specified in a *template-parameter*
62
  declaration. Types shall not be defined in a *template-parameter*
63
  declaration.
64
 
65
- A *type-parameter* whose identifier does not follow an ellipsis defines
 
66
  its *identifier* to be a *typedef-name* (if declared without `template`)
67
  or *template-name* (if declared with `template`) in the scope of the
68
  template declaration.
69
 
70
  [*Note 2*:
71
 
72
- A template argument may be a class template or alias template. For
73
  example,
74
 
75
  ``` cpp
76
  template<class T> class myarray { ... };
77
 
@@ -129,11 +134,11 @@ A *structural type* is one of the following:
129
  - an lvalue reference type, or
130
  - a literal class type with the following properties:
131
  - all base classes and non-static data members are public and
132
  non-mutable and
133
  - the types of all bases classes and non-static data members are
134
- structural types or (possibly multi-dimensional) array thereof.
135
 
136
  An *id-expression* naming a non-type *template-parameter* of class type
137
  `T` denotes a static storage duration object of type `const T`, known as
138
  a *template parameter object*, whose value is that of the corresponding
139
  template argument after it has been converted to the type of the
@@ -156,13 +161,13 @@ template<const X& x, int i, A a> void f() {
156
  i++; // error: change of template-parameter value
157
 
158
  &x; // OK
159
  &i; // error: address of non-reference template-parameter
160
  &a; // OK
161
- int& ri = i; // error: non-const reference bound to temporary
162
- const int& cri = i; // OK: const reference bound to temporary
163
- const A& ra = a; // OK: const reference bound to a template parameter object
164
  }
165
  ```
166
 
167
  — *end example*]
168
 
@@ -212,14 +217,14 @@ specified after `=` in a *template-parameter*. A default
212
  parameter pack [[temp.variadic]]. A default *template-argument* may be
213
  specified in a template declaration. A default *template-argument* shall
214
  not be specified in the *template-parameter-list*s of the definition of
215
  a member of a class template that appears outside of the member’s class.
216
  A default *template-argument* shall not be specified in a friend class
217
- template declaration. If a friend function template declaration
218
  specifies a default *template-argument*, that declaration shall be a
219
- definition and shall be the only declaration of the function template in
220
- the translation unit.
221
 
222
  The set of default *template-argument*s available for use is obtained by
223
  merging the default arguments from all prior declarations of the
224
  template in the same way default function arguments are
225
  [[dcl.fct.default]].
@@ -263,27 +268,15 @@ template<class... T, class... U> void f() { } // error
263
  template<class... T, class U> void g() { } // error
264
  ```
265
 
266
  — *end example*]
267
 
268
- A *template-parameter* shall not be given default arguments by two
269
- different declarations in the same scope.
270
-
271
- [*Example 8*:
272
-
273
- ``` cpp
274
- template<class T = int> class X;
275
- template<class T = int> class X { ... }; // error
276
- ```
277
-
278
- — *end example*]
279
-
280
  When parsing a default *template-argument* for a non-type
281
  *template-parameter*, the first non-nested `>` is taken as the end of
282
  the *template-parameter-list* rather than a greater-than operator.
283
 
284
- [*Example 9*:
285
 
286
  ``` cpp
287
  template<int i = 3 > 4 > // syntax error
288
  class X { ... };
289
 
@@ -296,11 +289,11 @@ class Y { ... };
296
  A *template-parameter* of a template *template-parameter* is permitted
297
  to have a default *template-argument*. When such default arguments are
298
  specified, they apply to the template *template-parameter* in the scope
299
  of the template *template-parameter*.
300
 
301
- [*Example 10*:
302
 
303
  ``` cpp
304
  template <template <class TT = float> class T> struct A {
305
  inline void f();
306
  inline void g();
@@ -326,11 +319,11 @@ unexpanded packs is a pack expansion. A type parameter pack with a
326
  *type-constraint* that contains an unexpanded parameter pack is a pack
327
  expansion. A template parameter pack that is a pack expansion shall not
328
  expand a template parameter pack declared in the same
329
  *template-parameter-list*.
330
 
331
- [*Example 11*:
332
 
333
  ``` cpp
334
  template <class... Types> // Types is a template type parameter pack
335
  class Tuple; // but not a pack expansion
336
 
 
28
  type-constraint:
29
  nested-name-specifierₒₚₜ concept-name
30
  nested-name-specifierₒₚₜ concept-name '<' template-argument-listₒₚₜ '>'
31
  ```
32
 
33
+ The component names of a *type-constraint* are its *concept-name* and
34
+ those of its *nested-name-specifier* (if any).
35
+
36
  [*Note 1*: The `>` token following the *template-parameter-list* of a
37
+ *type-parameter* can be the product of replacing a `>>` token by two
38
  consecutive `>` tokens [[temp.names]]. — *end note*]
39
 
40
  There is no semantic difference between `class` and `typename` in a
41
  *type-parameter-key*. `typename` followed by an *unqualified-id* names a
42
  template type parameter. `typename` followed by a *qualified-id* denotes
43
+ the type in a non-type[^1]
44
+
45
+ *parameter-declaration*. A *template-parameter* of the form `class`
46
+ *identifier* is a *type-parameter*.
47
 
48
  [*Example 1*:
49
 
50
  ``` cpp
51
  class T { ... };
 
64
 
65
  A storage class shall not be specified in a *template-parameter*
66
  declaration. Types shall not be defined in a *template-parameter*
67
  declaration.
68
 
69
+ The *identifier* in a *type-parameter* is not looked up. A
70
+ *type-parameter* whose *identifier* does not follow an ellipsis defines
71
  its *identifier* to be a *typedef-name* (if declared without `template`)
72
  or *template-name* (if declared with `template`) in the scope of the
73
  template declaration.
74
 
75
  [*Note 2*:
76
 
77
+ A template argument can be a class template or alias template. For
78
  example,
79
 
80
  ``` cpp
81
  template<class T> class myarray { ... };
82
 
 
134
  - an lvalue reference type, or
135
  - a literal class type with the following properties:
136
  - all base classes and non-static data members are public and
137
  non-mutable and
138
  - the types of all bases classes and non-static data members are
139
+ structural types or (possibly multidimensional) array thereof.
140
 
141
  An *id-expression* naming a non-type *template-parameter* of class type
142
  `T` denotes a static storage duration object of type `const T`, known as
143
  a *template parameter object*, whose value is that of the corresponding
144
  template argument after it has been converted to the type of the
 
161
  i++; // error: change of template-parameter value
162
 
163
  &x; // OK
164
  &i; // error: address of non-reference template-parameter
165
  &a; // OK
166
+ int& ri = i; // error: attempt to bind non-const reference to temporary
167
+ const int& cri = i; // OK, const reference binds to temporary
168
+ const A& ra = a; // OK, const reference binds to a template parameter object
169
  }
170
  ```
171
 
172
  — *end example*]
173
 
 
217
  parameter pack [[temp.variadic]]. A default *template-argument* may be
218
  specified in a template declaration. A default *template-argument* shall
219
  not be specified in the *template-parameter-list*s of the definition of
220
  a member of a class template that appears outside of the member’s class.
221
  A default *template-argument* shall not be specified in a friend class
222
+ template declaration. If a friend function template declaration D
223
  specifies a default *template-argument*, that declaration shall be a
224
+ definition and there shall be no other declaration of the function
225
+ template which is reachable from D or from which D is reachable.
226
 
227
  The set of default *template-argument*s available for use is obtained by
228
  merging the default arguments from all prior declarations of the
229
  template in the same way default function arguments are
230
  [[dcl.fct.default]].
 
268
  template<class... T, class U> void g() { } // error
269
  ```
270
 
271
  — *end example*]
272
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  When parsing a default *template-argument* for a non-type
274
  *template-parameter*, the first non-nested `>` is taken as the end of
275
  the *template-parameter-list* rather than a greater-than operator.
276
 
277
+ [*Example 8*:
278
 
279
  ``` cpp
280
  template<int i = 3 > 4 > // syntax error
281
  class X { ... };
282
 
 
289
  A *template-parameter* of a template *template-parameter* is permitted
290
  to have a default *template-argument*. When such default arguments are
291
  specified, they apply to the template *template-parameter* in the scope
292
  of the template *template-parameter*.
293
 
294
+ [*Example 9*:
295
 
296
  ``` cpp
297
  template <template <class TT = float> class T> struct A {
298
  inline void f();
299
  inline void g();
 
319
  *type-constraint* that contains an unexpanded parameter pack is a pack
320
  expansion. A template parameter pack that is a pack expansion shall not
321
  expand a template parameter pack declared in the same
322
  *template-parameter-list*.
323
 
324
+ [*Example 10*:
325
 
326
  ``` cpp
327
  template <class... Types> // Types is a template type parameter pack
328
  class Tuple; // but not a pack expansion
329