Date: Fri, 16 Aug 2019 11:07:00 -0500
On Fri, Aug 16, 2019 at 10:30 AM Ville Voutilainen <
ville.voutilainen_at_[hidden]> wrote:
> On Fri, 16 Aug 2019 at 18:23, Brian Bi <bbi5291_at_[hidden]> wrote:
> >> > There are two pack expansions here: `...xs=args` where the pattern is
> `xs=args`,
> >> That's not a pack expansion. It's a declaration of a captured pack,
> >> initialized from another pack. It does not
> >> and should not use a trailing ellipsis.
> > That's not what the plain text of the standard says (C++17
> [temp.variadic]/4):
> >> Pack expansions can occur in the following contexts: ... In a
> capture-list (8.1.5); the pattern is a capture.
>
> And you're quite sure that doesn't mean something like this?:
>
> template <class... Args> void f(Args&&... args) {
> [args...](){};
> }
>
Sorry, I didn't realize C++17 and C++20 are different about this. In the
working draft, either a *simple-capture* or an *init-capture* can be
expanded, and a *capture* is either *simple-capture* with optional
ellipsis, or an *init-capture* with optional ellipsis (which goes at the
beginning). So the plain reading of the standard is that `...xs=args` is a
pack expansion of the *init-capture* `xs=args`.
Besides, it does have the usual characteristics of a pack expansion: the
compiler sees the ellipsis next to "xs=args" and notionally produces
something like `xs#1 = args#1, ..., xs#n = args#n`.
ville.voutilainen_at_[hidden]> wrote:
> On Fri, 16 Aug 2019 at 18:23, Brian Bi <bbi5291_at_[hidden]> wrote:
> >> > There are two pack expansions here: `...xs=args` where the pattern is
> `xs=args`,
> >> That's not a pack expansion. It's a declaration of a captured pack,
> >> initialized from another pack. It does not
> >> and should not use a trailing ellipsis.
> > That's not what the plain text of the standard says (C++17
> [temp.variadic]/4):
> >> Pack expansions can occur in the following contexts: ... In a
> capture-list (8.1.5); the pattern is a capture.
>
> And you're quite sure that doesn't mean something like this?:
>
> template <class... Args> void f(Args&&... args) {
> [args...](){};
> }
>
Sorry, I didn't realize C++17 and C++20 are different about this. In the
working draft, either a *simple-capture* or an *init-capture* can be
expanded, and a *capture* is either *simple-capture* with optional
ellipsis, or an *init-capture* with optional ellipsis (which goes at the
beginning). So the plain reading of the standard is that `...xs=args` is a
pack expansion of the *init-capture* `xs=args`.
Besides, it does have the usual characteristics of a pack expansion: the
compiler sees the ellipsis next to "xs=args" and notionally produces
something like `xs#1 = args#1, ..., xs#n = args#n`.
-- *Brian Bi*
Received on 2019-08-16 11:09:14