
-------- Original-Nachricht --------
Datum: Thu, 11 Oct 2012 08:20:38 +0200 Von: "Oliver Kowalke" <oliver.kowalke@gmx.de> An: boost@lists.boost.org, boost@lists.boost.org Betreff: Re: [boost] [coroutine] new versions
I would like to see the coroutine-function with a void return type. Or have an option for that.
I've had such a version but I dropped it because for detecting the completeness of the coroutine would require an extra jump (return from last jump-function and calling return in the coroutine-fn). And this makes the implementation for iterators very painful:
void fn( coroutine<void(int)> & c) { c( 1); c( 2); }
The iterator would be required to be incremented three times. And std::distance would return 3 instead of 2.
If coroutine-fn is required to return void - we could detect the last 'caller_t::operator()' from coroutine-fn if we require to test the coroutine after each call: typedef coroutine< int() > coro1_t; typedef coroutine< void(int) > coro2_t; void fn( coro2_t & c) { c( 1); c( 2); } coro1_t c( fn); while ( c) { c(); if ( ! c) break; int res = c.get(); } Oliver