I remember hearing about this back at last years’ BoostCon, but never had a chance to absorb it until now. Chris Kohlhoff’s ASIO library contains an extraordinary little header, not in the public interface, but in the examples directory, that implements what he calls “Stackless Coroutines” (very similar to Python’s Simple Generators if you’re familiar with those). He does it completely portably, with just a few macros, and considering that there are zero lines of platform-specific code, they work amazingly well. This article explains how to use them. The ability to flatten callback-based code in this way is sorely missing from C++ (especially for asynchronous applications), so I thought this header deserved more notice. Frankly I’d like to see it as a top-level component in the Boost Utility library. Check it out!
On a related note, the Boost review of a “stackful” coroutine library by Oliver Kowalke is just now ending. This library makes different tradeoffs than Chris’ work does (it is arguably heavier-weight but less of a hack), but it too has great potential. If you get your review in quickly, there might even still be a chance to influence acceptance.