C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] async coroutines vs. lambdas
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-05-14 06:46:23


On Thu, 14 May 2020 at 14:34, Avi Kivity <avi_at_[hidden]> wrote:
> >> With a lambda coroutine, we have a problem. This is because lambdas are
> >> captured by reference:
> > Says what?
>
>
> Says the quote below, from cppreference.

Your wording was confusing; I thought you meant a lambda as a
coroutine parameter.
For cases where we are in a non-static member function, the *this is
indeed not copied.

> >> For a lambda, the non-static member function is
> >> synthetic_lambda_type::operator() const, and so the lambda would be
> >> captured as const synthetic_lambda_type&. Consider this call:
> > No. The lambda is the coroutine, not its operator().
>
>
> The first five words from cppreference are "A coroutine is a function".
> I know it is not authoritative, but I've seen nothing to contradict it.

Right, I was confused by whether we're wrapping a lambda or in a lambda.


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups