]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | |
2 | // Copyright Oliver Kowalke 2016. | |
3 | // Distributed under the Boost Software License, Version 1.0. | |
4 | // (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | #include <cstdlib> | |
8 | #include <iostream> | |
9 | #include <memory> | |
10 | ||
11 | #include <boost/context/continuation.hpp> | |
12 | ||
13 | namespace ctx = boost::context; | |
14 | ||
15 | int main() { | |
16 | int a; | |
17 | ctx::continuation c=ctx::callcc( | |
18 | [&a](ctx::continuation && c){ | |
19 | a=0; | |
20 | int b=1; | |
21 | for(;;){ | |
22 | c=c.resume(); | |
23 | int next=a+b; | |
24 | a=b; | |
25 | b=next; | |
26 | } | |
27 | return std::move( c); | |
28 | }); | |
29 | for ( int j = 0; j < 10; ++j) { | |
30 | std::cout << a << " "; | |
31 | c=c.resume(); | |
32 | } | |
33 | std::cout << std::endl; | |
34 | std::cout << "main: done" << std::endl; | |
35 | return EXIT_SUCCESS; | |
36 | } |