Last active
December 25, 2015 20:59
-
-
Save argv0/7038887 to your computer and use it in GitHub Desktop.
one can do some crazy stuff with c++11 and boost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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