2 // Copyright Keld Helsgaun 2000, 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)
7 #include <boost/coroutine/all.hpp>
12 #include <boost/bind.hpp>
13 #include <boost/move/move.hpp>
14 #include <boost/random/random_device.hpp>
15 #include <boost/random/uniform_int_distribution.hpp>
17 typedef boost::coroutines::symmetric_coroutine< void > coro_t;
24 boost::random::uniform_int_distribution<> dist( 1, 6);
28 void run_( coro_t::yield_type & yield)
31 while ( ( sum += die() ) < 100)
33 std::cout << "player " << id << " winns" << std::endl;
36 player( player const&);
37 player & operator=( player const&);
42 coro_t::call_type coro;
43 boost::random::random_device gen;
47 coro( boost::bind( & player::run_, this, _1) ),
55 int main( int argc, char * argv[])
57 player * first = new player( 1);
59 for ( int i = 2; i <= 4; ++i)
61 p->nxt = new player( i);
67 std::cout << "Done" << std::endl;