• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
10 #include <boost/coroutine2/all.hpp>
11 
main()12 int main() {
13     boost::coroutines2::coroutine< int >::pull_type source(
14         []( boost::coroutines2::coroutine< int >::push_type & sink) {
15             int first = 1, second = 1;
16             sink( first);
17             sink( second);
18             for ( int i = 0; i < 8; ++i) {
19                 int third = first + second;
20                 first = second;
21                 second = third;
22                 sink( third);
23             }
24         });
25     for ( auto i : source) {
26         std::cout << i <<  " ";
27     }
28     std::cout << "\nDone" << std::endl;
29     return EXIT_SUCCESS;
30 }
31