Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[temp.variadic] Clarify "pack expansion of its initialization" #5165

Open
xmh0511 opened this issue Dec 23, 2021 · 0 comments
Open

[temp.variadic] Clarify "pack expansion of its initialization" #5165

xmh0511 opened this issue Dec 23, 2021 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Dec 23, 2021

[temp.variadic] p3

An init-capture pack is a lambda capture that introduces an init-capture for each of the elements in the pack expansion of its initializer.

[temp.variadic] p4

The number of elements of an init-capture pack is the number of elements in the pack expansion of its initializer.

So, what does "pack expansion of its initializer" mean? We just define that

A pack expansion consists of a pattern and an ellipsis, ...

A pack whose name appears within the pattern of a pack expansion is expanded by that pack expansion.

In a capture-list ([expr.prim.lambda.capture]); the pattern is the capture without the ellipsis.

For example

template <typename... Args>
void foo(Args... args) {
    [...xs=args]{
        bar(xs...);             // xs is an init-capture pack
    };
}

...xs=args is a pack expansion where xs=args is the pattern, we say the pack args is expanded by this pack expansion; =args is the initializer in the init-capture pack. We never define "pack expansion of its initializer". This utterance is obscure in the current draft. Since we say:

An init-capture containing an ellipsis is a pack expansion that declares an init-capture pack

A pack expansion consists of a pattern and an ellipsis, the instantiation of which produces zero or more instantiations of the pattern in a list (described below).

thus, shouldn't we say

An init-capture pack is a lambda capture that introduces an init-capture for each of the elements that resulted from the instantiation of the init-capture that declares it.

?

As well as

The number of elements of an init-capture pack is the number of elements that resulted from the instantiation of its pack expansion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant