tmp/tmp25kp9qu8/{from.md → to.md}
RENAMED
|
@@ -43,12 +43,13 @@ the following contexts:
|
|
| 43 |
*type-parameter* without the ellipsis.
|
| 44 |
- In an *initializer-list* ([[dcl.init]]); the pattern is an
|
| 45 |
*initializer-clause*.
|
| 46 |
- In a *base-specifier-list* (Clause [[class.derived]]); the pattern is
|
| 47 |
a *base-specifier*.
|
| 48 |
-
- In a *mem-initializer-list* ([[class.base.init]])
|
| 49 |
-
*mem-initializer*
|
|
|
|
| 50 |
- In a *template-argument-list* ([[temp.arg]]); the pattern is a
|
| 51 |
*template-argument*.
|
| 52 |
- In a *dynamic-exception-specification* ([[except.spec]]); the pattern
|
| 53 |
is a *type-id*.
|
| 54 |
- In an *attribute-list* ([[dcl.attr.grammar]]); the pattern is an
|
|
@@ -58,10 +59,15 @@ the following contexts:
|
|
| 58 |
- In a *capture-list* ([[expr.prim.lambda]]); the pattern is a
|
| 59 |
*capture*.
|
| 60 |
- In a `sizeof...` expression ([[expr.sizeof]]); the pattern is an
|
| 61 |
*identifier*.
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
``` cpp
|
| 64 |
template<class ... Types> void f(Types ... rest);
|
| 65 |
template<class ... Types> void g(Types ... rest) {
|
| 66 |
f(&rest ...); // ``&rest ...'' is a pack expansion; ``&rest'' is its pattern
|
| 67 |
}
|
|
@@ -105,18 +111,28 @@ template<class ... Args>
|
|
| 105 |
The instantiation of a pack expansion that is not a `sizeof...`
|
| 106 |
expression produces a list
|
| 107 |
$\mathtt{E}_1, \mathtt{E}_2, ..., \mathtt{E}_N$, where N is the number
|
| 108 |
of elements in the pack expansion parameters. Each Eᵢ is generated by
|
| 109 |
instantiating the pattern and replacing each pack expansion parameter
|
| 110 |
-
with its ith element.
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
the
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
``` cpp
|
| 120 |
template<class... T> struct X : T... { };
|
| 121 |
template<class... T> void f(T... values) {
|
| 122 |
X<T...> x(values...);
|
|
|
|
| 43 |
*type-parameter* without the ellipsis.
|
| 44 |
- In an *initializer-list* ([[dcl.init]]); the pattern is an
|
| 45 |
*initializer-clause*.
|
| 46 |
- In a *base-specifier-list* (Clause [[class.derived]]); the pattern is
|
| 47 |
a *base-specifier*.
|
| 48 |
+
- In a *mem-initializer-list* ([[class.base.init]]) for a
|
| 49 |
+
*mem-initializer* whose *mem-initializer-id* denotes a base class; the
|
| 50 |
+
pattern is the *mem-initializer*.
|
| 51 |
- In a *template-argument-list* ([[temp.arg]]); the pattern is a
|
| 52 |
*template-argument*.
|
| 53 |
- In a *dynamic-exception-specification* ([[except.spec]]); the pattern
|
| 54 |
is a *type-id*.
|
| 55 |
- In an *attribute-list* ([[dcl.attr.grammar]]); the pattern is an
|
|
|
|
| 59 |
- In a *capture-list* ([[expr.prim.lambda]]); the pattern is a
|
| 60 |
*capture*.
|
| 61 |
- In a `sizeof...` expression ([[expr.sizeof]]); the pattern is an
|
| 62 |
*identifier*.
|
| 63 |
|
| 64 |
+
For the purpose of determining whether a parameter pack satisfies a rule
|
| 65 |
+
regarding entities other than parameter packs, the parameter pack is
|
| 66 |
+
considered to be the entity that would result from an instantiation of
|
| 67 |
+
the pattern in which it appears.
|
| 68 |
+
|
| 69 |
``` cpp
|
| 70 |
template<class ... Types> void f(Types ... rest);
|
| 71 |
template<class ... Types> void g(Types ... rest) {
|
| 72 |
f(&rest ...); // ``&rest ...'' is a pack expansion; ``&rest'' is its pattern
|
| 73 |
}
|
|
|
|
| 111 |
The instantiation of a pack expansion that is not a `sizeof...`
|
| 112 |
expression produces a list
|
| 113 |
$\mathtt{E}_1, \mathtt{E}_2, ..., \mathtt{E}_N$, where N is the number
|
| 114 |
of elements in the pack expansion parameters. Each Eᵢ is generated by
|
| 115 |
instantiating the pattern and replacing each pack expansion parameter
|
| 116 |
+
with its ith element. Such an element, in the context of the
|
| 117 |
+
instantiation, is interpreted as follows:
|
| 118 |
+
|
| 119 |
+
- if the pack is a template parameter pack, the element is a template
|
| 120 |
+
parameter ([[temp.param]]) of the corresponding kind (type or
|
| 121 |
+
non-type) designating the type or value from the template argument;
|
| 122 |
+
otherwise,
|
| 123 |
+
- if the pack is a function parameter pack, the element is an
|
| 124 |
+
*id-expression* designating the function parameter that resulted from
|
| 125 |
+
the instantiation of the pattern where the pack is declared.
|
| 126 |
+
|
| 127 |
+
All of the Eᵢ become elements in the enclosing list. The variety of list
|
| 128 |
+
varies with the context: *expression-list*, *base-specifier-list*,
|
| 129 |
+
*template-argument-list*, etc. When N is zero, the instantiation of the
|
| 130 |
+
expansion produces an empty list. Such an instantiation does not alter
|
| 131 |
+
the syntactic interpretation of the enclosing construct, even in cases
|
| 132 |
+
where omitting the list entirely would otherwise be ill-formed or would
|
| 133 |
+
result in an ambiguity in the grammar.
|
| 134 |
|
| 135 |
``` cpp
|
| 136 |
template<class... T> struct X : T... { };
|
| 137 |
template<class... T> void f(T... values) {
|
| 138 |
X<T...> x(values...);
|