-----Original Message-----
It was somehow disappointing that I couldn't simply do:
while (dijkstra_object() ) { }
You could instead, as in Daniel's example program a couple posts back, use a range 'for' over the dijkstra_object.
Yes, that would do perfectly.
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?
With a pull_type coroutine, the expectation is that every time it suspends (until it exits), it has produced a value for its consumer. If the coroutine constructor didn't enter the coroutine-function, the first invocation would have to be a special case.
To me it seems that the first invocation may either exit or produce a value, just as each subsequent invocation. I don't see the why the first invocation is special. I was also somehow expecting that the construction of the coroutines would be separate from there invocation, because I would assume that makes it easier to manage their appropriate execution order.
Even if that were desirable, how could you distinguish the case in which the coroutine produces zero values?
That case would just never enter the while loop.
That said, if you want finer-grained control over exactly when the coroutine is entered, you might consider using execution_context instead [0].
No, I don't want that. As a potential user I just thought it would be helpful to report where I found the interface (slightly) counterintuitive.