Could you post a complete compilable example, something with a clear metric for "works as intended"?  I can't follow these one-line snippets at all.

–Arthur

On Fri, May 22, 2020 at 12:55 PM Marcin Jaczewski via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
After some time playing around C++20 I find out that corutine can't
have local aware destructor.

code like this:
```
task<> foo(Storage& t, Args args);
```

Can use operator `new` like:
```
void* operator new(std::size_t s, Storage& t, Args args);
```

But destructor can only have two forms:
```
void operator delete(void* p, std::size_t s);
void operator delete(void* p);
```

This mean if I would want store this corutine in `Storage` then I have
now easy way to inform `Storage` to release memory for that corutine.

Could be possible for C++ support destructor like:
```
void operator delete(void* p, std::size_t s, Storage& t, Args args);
```

or at least new in C++20 destructor:
```
void operator delete(task_promise* p, std::destroying_delete_t);
```

second options will have benefit of not needed defining how exactly
args could survive to point of calling destructor as they should be
placed on allocated space by corutine.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals