C++ Logo


Advanced search

Re: Contradiction in the description of the pack expansion

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 16 Aug 2019 21:43:31 +0300
On Fri, 16 Aug 2019 at 19:07, Brian Bi <bbi5291_at_[hidden]> wrote:
>> 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`.

My bad, I shouldn't apply logic instead of looking at the wording. :)

Received on 2019-08-16 13:45:44