C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::generator initial_suspend dropping all temporaries out of scope

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Wed, 29 Jan 2025 06:38:09 +0000
You can have a wrapper function (not coroutine) that returns std::generator.

std::generator<T> wrapper(ReferenceType x) {
  return [](ValueType x)->std::generator<T>{
    /*implement coroutine*/
  }(DeepCopy(x));
}

DeepCopy(x) is evaluated before the initial suspend and its result lives on the coroutine frame.


On 28 January 2025 18:43:20 GMT, Karl Semich via Std-Proposals <std-proposals_at_[hidden]> wrote:
>--
>Std-Proposals mailing list
>Std-Proposals_at_[hidden]
>https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-01-29 06:38:18