C++ Logo

std-proposals

Advanced search

Re: [std-proposals] sizeof lambda in an unevaluated context

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 25 Jun 2024 16:56:49 -0700
On Tuesday 25 June 2024 16:29:14 GMT-7 Frederick Virchanza Gotham via Std-
Proposals wrote:
> Both lambdas capture 9 integers by reference.
>
> First one: sizeof([&args...](){})
>
> Second one: sizeof([&a,&b,&c,&d,&e,&f,&g,&h,&i](){})
>
> There ain't no capturing of pointers taking place (unless you're
> alluding to how compilers implement capture-by-reference by capturing
> memory addresses by value???)

Sorry, I didn't pay attention to the syntax and indeed &a is an integer
captured by reference, not a pointer to a.

Anyway, the point stands: with the loose definition as it is now, the compiler
was allowed to propagate the constants into the code. That's extremely
beneficial and should be allowed.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-06-25 23:56:53