|
735 | 735 | If a \grammarterm{template-parameter} is a
|
736 | 736 | \grammarterm{type-parameter} with an ellipsis prior to its
|
737 | 737 | optional \grammarterm{identifier} or is a
|
738 |
| -\grammarterm{parameter-declaration} that declares a parameter |
| 738 | +\grammarterm{parameter-declaration} that declares a |
739 | 739 | pack\iref{dcl.fct}, then the \grammarterm{template-parameter}
|
740 | 740 | is a template parameter pack\iref{temp.variadic}.
|
741 | 741 | A template parameter pack that is a \grammarterm{parameter-declaration} whose type
|
742 |
| -contains one or more unexpanded parameter packs is a pack expansion. Similarly, |
| 742 | +contains one or more unexpanded packs is a pack expansion. Similarly, |
743 | 743 | a template parameter pack that is a \grammarterm{type-parameter} with a
|
744 | 744 | \grammarterm{template-parameter-list} containing one or more unexpanded
|
745 |
| -parameter packs is a pack expansion. A template parameter pack that is a pack |
746 |
| -expansion shall not expand a parameter pack declared in the same |
| 745 | +packs is a pack expansion. A template parameter pack that is a pack |
| 746 | +expansion shall not expand a template parameter pack declared in the same |
747 | 747 | \grammarterm{template-parameter-list}.
|
748 | 748 | \begin{example}
|
749 | 749 | \begin{codeblock}
|
|
1418 | 1418 | \pnum A \grammarterm{template-argument} matches a template
|
1419 | 1419 | \grammarterm{template-parameter} \tcode{P} when
|
1420 | 1420 | \tcode{P} is at least as specialized as the \grammarterm{template-argument} \tcode{A}.
|
1421 |
| -If \tcode{P} contains a parameter pack, then \tcode{A} also matches \tcode{P} |
| 1421 | +If \tcode{P} contains a template parameter pack, then \tcode{A} also matches \tcode{P} |
1422 | 1422 | if each of \tcode{A}'s template parameters
|
1423 | 1423 | matches the corresponding template parameter in the
|
1424 | 1424 | \grammarterm{template-head} of \tcode{P}.
|
|
1514 | 1514 | for each template parameter \tcode{PP}
|
1515 | 1515 | in the \grammarterm{template-head} of the function template,
|
1516 | 1516 | a corresponding template argument \tcode{AA} is formed.
|
1517 |
| -If \tcode{PP} declares a parameter pack, |
| 1517 | +If \tcode{PP} declares a template parameter pack, |
1518 | 1518 | then \tcode{AA} is the pack expansion \tcode{PP...}\iref{temp.variadic};
|
1519 | 1519 | otherwise, \tcode{AA} is the \grammarterm{id-expression} \tcode{PP}.
|
1520 | 1520 | \end{itemize}
|
|
2531 | 2531 | \begin{codeblock}
|
2532 | 2532 | template<class ... Types> void f(Types ... args);
|
2533 | 2533 |
|
2534 |
| -f(); // OK: \tcode{args} contains no arguments |
2535 |
| -f(1); // OK: \tcode{args} contains one argument: \tcode{int} |
2536 |
| -f(2, 1.0); // OK: \tcode{args} contains two arguments: \tcode{int} and \tcode{double} |
| 2534 | +f(); // \tcode{args} contains no arguments |
| 2535 | +f(1); // \tcode{args} contains one argument: \tcode{int} |
| 2536 | +f(2, 1.0); // \tcode{args} contains two arguments: \tcode{int} and \tcode{double} |
2537 | 2537 | \end{codeblock}
|
2538 | 2538 | \end{example}
|
2539 | 2539 |
|
2540 | 2540 | \pnum
|
2541 |
| -A \defn{parameter pack} is either a template parameter |
2542 |
| -pack or a function parameter pack. |
| 2541 | +An \defnx{\grammarterm{init-capture} pack}{init-capture pack@\fakegrammarterm{init-capture} pack} |
| 2542 | +is a lambda capture that introduces an \grammarterm{init-capture} |
| 2543 | +for each of the elements in the pack expansion of its \grammarterm{initializer}. |
| 2544 | +\begin{example} |
| 2545 | +\begin{codeblock} |
| 2546 | +template <typename... Args> |
| 2547 | +void foo(Args... args) { |
| 2548 | + [...xs=args]{ |
| 2549 | + bar(xs...); // \tcode{xs} is an \grammarterm{init-capture} pack |
| 2550 | + }; |
| 2551 | +} |
| 2552 | + |
| 2553 | +foo(); // \tcode{xs} contains zero \grammarterm{init-captures} |
| 2554 | +foo(1); // \tcode{xs} contains one \grammarterm{init-capture} |
| 2555 | +\end{codeblock} |
| 2556 | +\end{example} |
| 2557 | + |
| 2558 | +\pnum |
| 2559 | +A \defn{pack} is |
| 2560 | +a template parameter pack, |
| 2561 | +a function parameter pack, |
| 2562 | +or an \grammarterm{init-capture} pack. |
| 2563 | +The number of elements of a template parameter pack |
| 2564 | +or a function parameter pack |
| 2565 | +is the number of arguments provided for the parameter pack. |
| 2566 | +The number of elements of an \grammarterm{init-capture} pack |
| 2567 | +is the number of elements in the pack expansion of its \grammarterm{initializer}. |
2543 | 2568 |
|
2544 | 2569 | \pnum
|
2545 | 2570 | \indextext{pattern|see{pack expansion, pattern}}%
|
|
2595 | 2620 |
|
2596 | 2621 | \item In a \grammarterm{fold-expression}\iref{expr.prim.fold};
|
2597 | 2622 | the pattern is the \grammarterm{cast-expression}
|
2598 |
| -that contains an unexpanded parameter pack. |
| 2623 | +that contains an unexpanded pack. |
2599 | 2624 | \end{itemize}
|
2600 | 2625 |
|
2601 | 2626 | \begin{example}
|
|
2608 | 2633 | \end{example}
|
2609 | 2634 |
|
2610 | 2635 | \pnum
|
2611 |
| -For the purpose of determining whether a parameter pack satisfies a rule |
2612 |
| -regarding entities other than parameter packs, the parameter pack is |
| 2636 | +For the purpose of determining whether a pack satisfies a rule |
| 2637 | +regarding entities other than packs, the pack is |
2613 | 2638 | considered to be the entity that would result from an instantiation of
|
2614 | 2639 | the pattern in which it appears.
|
2615 | 2640 |
|
2616 | 2641 | \pnum
|
2617 |
| -A parameter pack whose name appears within the pattern of a pack |
| 2642 | +A pack whose name appears within the pattern of a pack |
2618 | 2643 | expansion is expanded by that pack expansion. An appearance of the name of
|
2619 |
| -a parameter pack is only expanded by the innermost enclosing pack expansion. |
2620 |
| -The pattern of a pack expansion shall name one or more parameter packs that |
2621 |
| -are not expanded by a nested pack expansion; such parameter packs are called |
2622 |
| -\defnx{unexpanded parameter packs}{parameter pack!unexpanded} in the pattern. All of the parameter packs expanded |
| 2644 | +a pack is only expanded by the innermost enclosing pack expansion. |
| 2645 | +The pattern of a pack expansion shall name one or more packs that |
| 2646 | +are not expanded by a nested pack expansion; such packs are called |
| 2647 | +\defnx{unexpanded packs}{pack!unexpanded} in the pattern. All of the packs expanded |
2623 | 2648 | by a pack expansion shall have the same number of arguments specified. An
|
2624 |
| -appearance of a name of a parameter pack that is not expanded is |
| 2649 | +appearance of a name of a pack that is not expanded is |
2625 | 2650 | ill-formed. \begin{example}
|
2626 | 2651 |
|
2627 | 2652 | \begin{codeblock}
|
|
2642 | 2667 | template<class ... Args>
|
2643 | 2668 | void g(Args ... args) { // OK: \tcode{Args} is expanded by the function parameter pack \tcode{args}
|
2644 | 2669 | f(const_cast<const Args*>(&args)...); // OK: ``\tcode{Args}'' and ``\tcode{args}'' are expanded
|
2645 |
| - f(5 ...); // error: pattern does not contain any parameter packs |
2646 |
| - f(args); // error: parameter pack ``\tcode{args}'' is not expanded |
| 2670 | + f(5 ...); // error: pattern does not contain any packs |
| 2671 | + f(args); // error: pack ``\tcode{args}'' is not expanded |
2647 | 2672 | f(h(args ...) + args ...); // OK: first ``\tcode{args}'' expanded within \tcode{h},
|
2648 | 2673 | // second ``\tcode{args}'' expanded within \tcode{f}
|
2649 | 2674 | }
|
|
2656 | 2681 | that is neither a \tcode{sizeof...} expression
|
2657 | 2682 | nor a \grammarterm{fold-expression}
|
2658 | 2683 | produces a
|
2659 |
| -list |
2660 |
| -$\mathtt{E}_1, \mathtt{E}_2, \dotsc, \mathtt{E}_N$, |
| 2684 | +list of elements |
| 2685 | +$\mathtt{E}_1,$ $\mathtt{E}_2,$ $\cdots,$ $\mathtt{E}_N$, |
2661 | 2686 | where
|
2662 | 2687 | $N$ is the number of elements in the pack expansion parameters. Each
|
2663 | 2688 | $\mathtt{E}_i$ is generated by instantiating the pattern and
|
2664 |
| -replacing each pack expansion parameter with its $i$th element. |
| 2689 | +replacing each pack expansion parameter with its $i^{\textrm{th}}$ element. |
2665 | 2690 | Such an element, in the context of the instantiation, is interpreted as
|
2666 | 2691 | follows:
|
2667 | 2692 |
|
2668 | 2693 | \begin{itemize}
|
2669 | 2694 | \item
|
2670 | 2695 | if the pack is a template parameter pack, the element is a template
|
2671 | 2696 | parameter\iref{temp.param} of the corresponding kind (type or
|
2672 |
| -non-type) designating the type or value from the template |
2673 |
| -argument; otherwise, |
| 2697 | +non-type) designating the $i^{\textrm{th}}$ |
| 2698 | +corresponding type or value template argument; |
2674 | 2699 |
|
2675 | 2700 | \item
|
2676 | 2701 | if the pack is a function parameter pack, the element is an
|
2677 | 2702 | \grammarterm{id-expression}
|
2678 |
| -designating the function parameter that resulted from |
2679 |
| -the instantiation of the pattern where the pack is declared. |
| 2703 | +designating the $i^{\textrm{th}}$ function parameter |
| 2704 | +that resulted from instantiation of |
| 2705 | +the function parameter pack declaration; |
| 2706 | +otherwise |
| 2707 | + |
| 2708 | +\item |
| 2709 | +if the pack is an \grammarterm{init-capture} pack, |
| 2710 | +the element is an \grammarterm{id-expression} |
| 2711 | +designating the variable introduced by |
| 2712 | +the $i^{\textrm{th}}$ \grammarterm{init-capture} |
| 2713 | +that resulted from instantiation of |
| 2714 | +the \grammarterm{init-capture} pack. |
2680 | 2715 | \end{itemize}
|
2681 | 2716 |
|
2682 |
| -All of the $\mathtt{E}_i$ become elements in the enclosing list. |
| 2717 | +All of the $\mathtt{E}_i$ become items in the enclosing list. |
2683 | 2718 | \begin{note} The variety of list varies with the context:
|
2684 | 2719 | \grammarterm{expression-list},
|
2685 | 2720 | \grammarterm{base-specifier-list},
|
|
2702 | 2737 |
|
2703 | 2738 | \pnum
|
2704 | 2739 | The instantiation of a \tcode{sizeof...} expression\iref{expr.sizeof} produces
|
2705 |
| -an integral constant containing the number of elements in the parameter pack |
| 2740 | +an integral constant containing the number of elements in the pack |
2706 | 2741 | it expands.
|
2707 | 2742 |
|
2708 | 2743 | \pnum
|
|
2745 | 2780 | For a binary fold-expression,
|
2746 | 2781 | $\mathtt{E}$ is generated
|
2747 | 2782 | by instantiating the \grammarterm{cast-expression}
|
2748 |
| -that did not contain an unexpanded parameter pack. |
| 2783 | +that did not contain an unexpanded pack. |
2749 | 2784 | \begin{example}
|
2750 | 2785 | \begin{codeblock}
|
2751 | 2786 | template<typename ...Args>
|
|
2766 | 2801 | \begin{floattable}{Value of folding empty sequences}{tab:fold.empty}
|
2767 | 2802 | {ll}
|
2768 | 2803 | \topline
|
2769 |
| -\lhdr{Operator} & \rhdr{Value when parameter pack is empty} \\ |
| 2804 | +\lhdr{Operator} & \rhdr{Value when pack is empty} \\ |
2770 | 2805 | \capsep
|
2771 | 2806 | \tcode{\&\&} & \tcode{true} \\
|
2772 | 2807 | \tcode{||} & \tcode{false} \\
|
|
3152 | 3187 | The template parameter list of a specialization shall not contain default
|
3153 | 3188 | template argument values.\footnote{There is no way in which they could be used.}
|
3154 | 3189 | \item
|
3155 |
| -An argument shall not contain an unexpanded parameter pack. If |
| 3190 | +An argument shall not contain an unexpanded pack. If |
3156 | 3191 | an argument is a pack expansion\iref{temp.variadic}, it shall be
|
3157 | 3192 | the last argument in the template argument list.
|
3158 | 3193 | \end{itemize}
|
|
4739 | 4774 | the partial specialization enclosed in
|
4740 | 4775 | \tcode{<>} (or an equivalent template alias specialization).
|
4741 | 4776 | If the \textit{n}th template parameter is
|
4742 |
| -a parameter pack, the \textit{n}th template argument is a pack |
| 4777 | +a template parameter pack, the \textit{n}th template argument is a pack |
4743 | 4778 | expansion\iref{temp.variadic} whose pattern is the name of
|
4744 |
| -the parameter pack. |
| 4779 | +the template parameter pack. |
4745 | 4780 | \end{itemize}
|
4746 | 4781 |
|
4747 | 4782 | \pnum
|
|
7209 | 7244 | \begin{note}
|
7210 | 7245 | Type deduction may fail for the following reasons:
|
7211 | 7246 | \begin{itemize}
|
7212 |
| -\item Attempting to instantiate a pack expansion containing multiple parameter packs of differing lengths. |
| 7247 | +\item Attempting to instantiate a pack expansion containing multiple packs of differing lengths. |
7213 | 7248 | \item
|
7214 | 7249 | Attempting to create an array with an element type that is \tcode{void}, a
|
7215 | 7250 | function type, a reference type, or an abstract class type, or attempting
|
|
7391 | 7426 | Each deduction deduces template arguments for subsequent positions in
|
7392 | 7427 | the template parameter packs expanded by the function parameter pack.
|
7393 | 7428 | When a function parameter pack appears in a non-deduced
|
7394 |
| -context\iref{temp.deduct.type}, the type of that parameter pack is |
| 7429 | +context\iref{temp.deduct.type}, the type of that pack is |
7395 | 7430 | never deduced.
|
7396 | 7431 | \begin{example}
|
7397 | 7432 | \begin{codeblock}
|
|
0 commit comments