I have a few questions about the implementation of the function then() in Herb Sutter\'s talk. This function is used to chain asynchronous operations, the param
In order to simplify the interface, I would "hide" the void problem inside the implementation, similarly to what Herb did with his concurrent implementation. Instead of having 2 then implementations, declare a helper function get_work_done with 2 implementations:
template
auto get_work_done(future &f, Work &w)-> decltype(w(f.get()))
{return w(f.get());}
template
auto get_work_done(future &f, Work &w)-> decltype(w())
{f.wait(); return w();}
And then let template parameter detection take care of the rest:
template
auto then(future f, Work w) -> future
{
return async([](future f, Work w)
{ return get_work_done(f,w); }, move(f), move(w));
}