]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // Copyright Oliver Kowalke 2014. | |
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/all.hpp> | |
12 | ||
13 | namespace ctx = boost::context; | |
14 | ||
15 | int main() { | |
16 | int n=35; | |
17 | ctx::execution_context< int > source( | |
18 | [n](ctx::execution_context< int > sink, int) mutable { | |
19 | int a=0; | |
20 | int b=1; | |
21 | while(n-->0){ | |
22 | auto result=sink(a); | |
23 | sink=std::move(std::get<0>(result)); | |
24 | auto next=a+b; | |
25 | a=b; | |
26 | b=next; | |
27 | } | |
28 | return sink; | |
29 | }); | |
30 | for(int i=0;i<10;++i){ | |
31 | auto result=source(i); | |
32 | source=std::move(std::get<0>(result)); | |
33 | std::cout<<std::get<1>(result)<<" "; | |
34 | } | |
35 | std::cout<<std::endl; | |
36 | ||
37 | std::cout << "main: done" << std::endl; | |
38 | } |