]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/coroutine/example/asymmetric/fibonacci.cpp
2 // Copyright Oliver Kowalke 2009.
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)
10 #include <boost/range.hpp>
11 #include <boost/coroutine/all.hpp>
13 void fibonacci( boost::coroutines::asymmetric_coroutine
< int >::push_type
& sink
)
15 int first
= 1, second
= 1;
20 int third
= first
+ second
;
29 boost::coroutines::asymmetric_coroutine
< int >::pull_type
source( fibonacci
);
30 boost::range_iterator
<
31 boost::coroutines::asymmetric_coroutine
< int >::pull_type
32 >::type
it( boost::begin( source
) );
33 for ( int i
= 0; i
< 10; ++i
)
35 std::cout
<< * it
<< " ";
39 std::cout
<< "\nDone" << std::endl
;