3 ms·
This article discusses things that are totally irrelevant to someone who will actually use coroutines, because they will use https://github.com/lewissbaker/cppc
by gsliepen 5y ago
This article discusses things that are totally irrelevant to someone who will actually use coroutines, because they will use https://github.com/lewissbaker/cppcoro https://github.com/lewissbaker/cppcoro or wait for C++23 to give them the library support for coroutines, which will make usage simple, like the first code snippet from the article.
- gpderetta 5y agoThe unreliable allocation elision is very relevant for most coroutine users. edit: also the lack of composability is relevant.
- gsliepen 5y agoIt is possible to compose them more easily than described in the article; Lewis Baker's cppcoro library for example provides a recursive_generator<> type[0] that allows this without using any macros. It's up to the library part of coroutines to make things easy, end users are not expected to write low-level coroutine code themselves. I wonder about the allocation elision. Return value optimization became mandatory, and some compilers can already elide calls to new/delete and malloc()/free() in normal code, so perhaps it will be possible to guarantee allocation elision in the future in the most used cases. [0]: https://github.com/lewissbaker/cppcoro#recursive_generatort https://github.com/lewissbaker/cppcoro#recursive_generatort