On 01/04/2015 11:25 AM, Thomas Heller wrote:
What's the difference between async_result and a future? I am unable to find that in the ASIO documentation.
async_result is like a return type trait. In its generalized form in Asio it supports callbacks, but has be specialized for futures and coroutines. Other mechanisms can be added; for instance, Boost.Fiber comes with an async_result specialization. The important point with that design is that with async_result the user of an asynchronous function gets to decide which mechanism to use. Examples: // Callback socket.async_send(buffer, [] (error_code, size_t) { }); // Future auto myfuture = socket.async_send(buffer, use_future); // Coroutine socket.async_send(buffer, yield);