C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] async coroutines vs. lambdas
From: Avi Kivity (avi_at_[hidden])
Date: 2020-05-14 06:59:42


On 5/14/20 2:46 PM, Ville Voutilainen wrote:
> 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.

Ah, the lambda _is_ a coroutine parameter in a sense, if you follow the
regular translation of a lambda to a struct with operator().

And note this is not specific to lambdas, it happens for any member
coroutine called on a temporary. A lambda is just the most common way of
generating such calls.


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

Standard Proposals Archives on Google Groups