Boost logo

Boost :

Subject: Re: [boost] [coroutine] new versions
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2012-10-11 09:43:23


> auto fn(coroutine<string(int)> c) {
> assert(!c.has_data());
> c(10);
> assert(c.has_data() && c.get() == "abc");
> return c;
> }
>
> coroutine< int( string) > c( fn);
> assert(c.has_data() && c.get() == 10);
> c( "abc");
> assert(c.terminated());

as in one of the previous examples - your example does not work if the return value depends on the arguments passed to coroutine

void fn( coroutine<string(int)> & c) {
  string s = c.get();
  if ( s == "abc") c(10);
  else c( 20);
  ...
}

the question is:

- does the first invocation of 'coroutine<>::operator()' enter the body of coroutine-fn (in the example above the first instruction is 'string s = c.get()')

- or the first call to 'coroutine<>::operator()' might jump to somewhere in the body of coroutine-fn (in the example from Giovanni it returns from c(10))

Oliver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk