Skip to content

Instantly share code, notes, and snippets.

@argv0
Last active December 25, 2015 20:59
Show Gist options
  • Save argv0/7038887 to your computer and use it in GitHub Desktop.
Save argv0/7038887 to your computer and use it in GitHub Desktop.
one can do some crazy stuff with c++11 and boost
#include <cstdlib>
#include <iostream>
#include <boost/coroutine/all.hpp>
using namespace boost::coroutines;
using namespace std;
int main()
{
coroutine< int() > c(
[&]( coroutine< void( int) > & c) {
int first = 1, second = 1;
for ( int i = 0; i < 10; ++i)
{
int third = first + second;
first = second;
second = third;
c( third);
}
});
for ( auto i : c) cout << i << " ";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment