-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Nat Goodspeed Sent: 19 January 2016 21:25 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Using Coroutines in the Visitor Pattern (use-case: BGL event visitor)
On Tue, Jan 19, 2016 at 6:02 AM, alex
wrote: I can see in the documentation that the constructor enters the coroutine- function, but it is not clear to me why. Would it not have been neater if this was avoided?
[...]
If the coroutine constructor didn't enter the coroutine-function, the first invocation would have to be a special case.
[...]
I expect the following in the evaluation of the while condition
1.The operator () will enter somefunc().
It is dawning on me now. At the first invocation operator() should enter somefunc(), whereas at all subsequent invocations it has to re-enter somefunc(). I suppose enter and re-enter are different operations, hence the first invocation would be a special case. Thanks for indulging me.