|
|
|
|
|
by convery
1213 days ago
|
|
TBH, everytime I read about coroutines and their example usages I get stuck on the "why" question. If the example is a function waiting for data, a std::future seems a lot easier. If the example is a generator, a range/transform/filter or just a class that returns a std::default_sentinel iterator seems more appropriate. The only reason I can see is lowering the overhead of creating threads, at the cost of harder to read controlflow. |
|
Also, generators can be used to turn traversal functions into iterators, which is often tedious to do by hand.