https://github.com/grisumbras/corots
An attempt to implement Coroutines TS (N4760) as a library on top of resumable expressions (P0114R0)
https://github.com/grisumbras/corots
coroutines cpp cxx
Last synced: over 1 year ago
JSON representation
An attempt to implement Coroutines TS (N4760) as a library on top of resumable expressions (P0114R0)
- Host: GitHub
- URL: https://github.com/grisumbras/corots
- Owner: grisumbras
- License: bsl-1.0
- Created: 2018-09-16T08:07:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T11:11:49.000Z (almost 8 years ago)
- Last Synced: 2025-01-25T09:12:36.400Z (over 1 year ago)
- Topics: coroutines, cpp, cxx
- Language: C++
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# corots
> An attempt to implement Coroutines TS (N4760) as a library on top of
> resumable expressions (P0114R0) with some modifications.
## Usage
First, note, that it doesn't actually work, because both resumable object and
`break resumable` (the core functionality of resumable expressions) are
currently stubs. I am planning on integrating Chris Kohlhoff's prototype
(that uses stackfull coroutines from Boost) into this project.
Other than that, there had to be some changes in usage with regards to TS,
because it relies on some code transformations, and a library-only solution
cannot do that.
Where with TS you'd write
```c++
generator my_generator() {
co_yield 1;
}
int main() {
for (auto n: my_generator()) {
std::cout << n;
}
}
```
with this library you'd write
```c++
#include
auto constexpr m_generator = corots::coroutine>(
[](auto& promise){
corots::yield(promise, 1);
}
);
int main() {
for (auto n: my_generator()) {
std::cout << n;
}
}
```