yyzybb537 / libgo

Go-style concurrency in C++11
MIT License
3.18k stars 754 forks source link

支持协程迭代器吗? #305

Open consolexinhun opened 10 months ago

consolexinhun commented 10 months ago

这个支持协程迭代器吗?类似 boost 的 coroutine 的协程迭代器

void foo2(boost::coroutines2::coroutine<int>::pull_type & sink) {
    for (auto val : sink) {
        std::cout << "retrieve " << val << "\n";

    }

}

int main(){
    boost::coroutines2::coroutine<int>::push_type source(foo);

    for (int i = 0; i < 10; i++) {
        source(i);

    }

    return 0;

}

想要一个这样的功能