Marcin Jaczewski
unread,May 21, 2020, 6:18:56 PM5/21/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to std-pr...@isocpp.org
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.