Boost logo

Boost :

Subject: Re: [boost] combinations and permutations
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-01-06 07:40:10


On 05/01/2011 15:38, Howard Hinnant wrote:
> I looked at:
>
> http://en.wikipedia.org/wiki/Coroutine
>
> and was unsuccessful in translating that idea to this application. Perhaps you could elaborate?

Look at the first example on that page, produce/consume: your
for_each-style algorithm is similar to the 'produce' coroutine, and
iteration of ranges is similar to the 'consume' coroutine.

Coroutines are typically implemented in C++ by storing the current
context somewhere (registers, stack, PC), and switching to another
context. This can be done in assembler or using OS-specific routines.

It's similar to threads, except there is no scheduler, typically no
kernel, and no concurrency involved.

There is a Boost.Coroutine library somewhere, if you want to try it. I
wrote some code with it that converts a for_each-style mechanism into a
classic pair of iterators, if you're interested.


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