C++ Logo

std-proposals

Advanced search

Re: [std-proposals] lambda capture rules are too simplistic

From: blacktea hamburger <greenteahamburger_at_[hidden]>
Date: Sat, 1 Oct 2022 21:44:07 +0800
The standard can specify that it is not captured. I don't think it's good
to pin hopes of optimization on implementations.

On Sat, Oct 1, 2022 at 9:31 PM Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Sat, Oct 1, 2022 at 8:41 AM blacktea hamburger via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > You have a point.
> >
> > But for non-generic lambdas, there should be no additional capture. Such
> as:
> >
> > const int n = 1;
> > [=] {int arr[n];};
>
> Where is the "additional capture"?
>
> Your lambda asked to capture everything if it is mentioned. I see `n`
> being mentioned in the lambda body. It is not at all unreasonable for
> a lambda to capture it. And a compiler can always optimize it away,
> but there's no problem with having `n` be captured.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-10-01 13:44:36