Date: Sun, 14 Mar 2021 01:07:35 -0500

On Mon, Mar 8, 2021 at 3:06 AM jim x via Std-Discussion <

std-discussion_at_[hidden]> wrote:

>

> In the current draft, there are two issues about the instantiation for a

fold-expression.

> The first is the standard seems not clear for stating which are the

elements of the pack expansion parameters that appear in the pattern of

fold-expression. It could be assumed they're stated in paragraph 8

[temp.variadic#8]

>

> However, such a layout of the rule seems that the description for what

these elements of pack expansion parameters are is only applying to the

case that is: `the instantiation of a pack expansion that is neither a

sizeof... expression nor a fold-expression`.

>

> Is it necessary to take the rule out from paragraph 8 to be an individual

rule? That would cover the case that what these elements of the pack

expansion parameters are which appears in the fold-expression.

I agree, it would make sense if things were rearranged so that

subparagraphs (8.1)-(8.3) also applied to fold-expressions. Perhaps

something like:

std-discussion_at_[hidden]> wrote:

>

> In the current draft, there are two issues about the instantiation for a

fold-expression.

> The first is the standard seems not clear for stating which are the

elements of the pack expansion parameters that appear in the pattern of

fold-expression. It could be assumed they're stated in paragraph 8

[temp.variadic#8]

>

> However, such a layout of the rule seems that the description for what

these elements of pack expansion parameters are is only applying to the

case that is: `the instantiation of a pack expansion that is neither a

sizeof... expression nor a fold-expression`.

>

> Is it necessary to take the rule out from paragraph 8 to be an individual

rule? That would cover the case that what these elements of the pack

expansion parameters are which appears in the fold-expression.

I agree, it would make sense if things were rearranged so that

subparagraphs (8.1)-(8.3) also applied to fold-expressions. Perhaps

something like:

---- [Paragraph 8]: <del>The instantiation of a pack expansion that is neither a sizeof... expression nor a *fold-expression* produces</del> <ins>The *expanded pack list* for an instantiation of a pack expansion that is not a sizeof... expression is</ins> a list of elements... [(8.3)] ... the init capture-pack. [Add paragraph break and renumber.] <del>All of the E_i become</del> <ins>The instantiation of a pack expansion that is neither a sizeof... expression nor a *fold-expression* produces the elements of the expanded pack list as</ins> items in the enclosing list. [Here, keep the following note, normative sentences, and example from the original paragraph 8.] [Paragraph 10]: In each case, *op* is the *fold-operator*, *N* is the number of elements in the pack expansion parameters, and <del>each E_i is generated by instantiating the pattern and replacing each pack expansion parameter with its i-th element.</del> <ins>the expressions E_i are the elements of the expanded pack list.</ins> For a binary ... ---- > > The second issue is about the **binary fold-expression** when the number of the elements is zero. The whole paragraph 10 only talks about how the result is for the unary fold-expression when the number of the elements is zero. It lacks the case of a binary fold-expression. (Presumably, the result of this case is that of the expression `E` that didn't contain an unexpanded pack). I don't think any changes are needed here. The descriptions of the instantiations use the informal ellipsis as often seen in mathematical formulas. The meaning of that type of formula, although seldom defined in very strict detail, is very widely understood as a pattern giving a formula involving K values/operands and K-1 operators, as long as K>=1. The K=0 case is in general not valid, but there can be other conventions, stated or unstated, about what it means then, just as we see C++ defining explicitly for unary fold-expressions with N=0. (In mathematical writing, it's often assumed if the operation is called "addition" the result is the set's appropriate "zero", and if the operation is called "multiplication" the result is the set's appropriate "one".) So a binary fold-expression where N=0 is a case of the informal ellipsis with K=1, and yes, the result is E. This is no more or less ambiguous than a unary fold-expression where N=1, since for interpretation of the informal ellipsis pattern, the fact that E has different properties than the E_i expressions doesn't matter. -- Andrew Schepler > -- > Std-Discussion mailing list > Std-Discussion_at_[hidden] > https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2021-03-14 00:07:49