thanks Oliver,Nate,
boost.coroutine required some fixes releated C++11 and iterators (thank you nate) - the fixes are applied to trunk and should be available in boost-1.54.2013/2/18 Nathan Ridge <zeratul976@hotmail.com>
Turns out that the final version of Boost.Coroutine that made it
into the 1.53 release has out-of-the-box support for treating the
values returned by a coroutine as a range, which makes writing such
an outputs_of() function trivial:
using boost::coroutines::coroutine;
...
template <typename T, typename F>
coroutine<T()> outputs_of(F f)
{
return coroutine<T()>{[f](typename coroutine<T()>::caller_type& caller)
{
f(boost::make_function_output_iterator([&caller](const T& t){ caller(t); }));
}};
}
A complete example using the two functions in your original post is
attached.
The code uses some C++11 features like lambdas, but these can
easily be translated to their C++03 equivalents if necessary.
I'll leave it to you as an exercise to do that if you need to.
Hope that helps!
Regards,
Nate
Oliver
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users