|
Boost : |
Subject: Re: [boost] {Review] Coroutine reviewstarts today, September 3rd
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2012-09-08 01:59:16
Hello Eugene,
Am 04.09.2012 01:30, schrieb Eugene Yakubovich:
> 1. What is the rationale for having the generator-function's return
> statement be used to return the last generated value or forcing the
> use of yield_break (which uses exceptions that can be slow). My only
> experience with generators/coroutines has been in Python which might
> have biased my view but I think having the generator-function return
> void would be more natural (and would eliminate the need for
> yield_break). For example, if I wanted to generate a sequence of
> evens, I could write:
>
> typedef boost::coro::generator< int > gen_t;
>
> gen_t evens(int cnt) {
> return [=](gen_t::self_t& self) {
> for( int i = 0; i < cnt; i++ )
> self.yield(i*2);
> };
> }
I managed to implement your suggestion - generator-functions are required to
return void and generator<>::self_t::yield() accepts the return type
specified as template arg of generator<>.
generator<>::self_t::yield_break() was removed.
The code is available under git://gitorious.org/boost-dev/boost-dev.git
(branch coroutine).
regards,
Oliver
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk