|
Boost : |
Subject: Re: [boost] [coroutine] new versions
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2012-10-11 09:19:05
On Thu, Oct 11, 2012 at 1:44 PM, Oliver Kowalke <oliver.kowalke_at_[hidden]>wrote:
> > > > Also, the coroutine-fn is called immediately when
> > > > the coroutine is called, and not deferred to the first operator()
> > call.
> > >
> > > I don't get it - when will be the body of coroutine-fn entered?
> > >
> > > coro_t c( fn);//?
> > > or
> > > c(); //?
> > >
> >
> > The first option.
>
> what if the coroutine-fn expects some arguments?
>
> coroutine< int( string) > c( fn);
> c( "abc");
>
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());
-- gpd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk