On 9/09/2019 19:47, Klebsch, Mario wrote:
For example:
operator()() -> kicks off first async_wait operator()(error_code) -> handles result of async_wait and kicks off async_read operator()(error_code, size_t) -> handles result of async_read and kicks off another async_wait
I sometimes use a single operator() with default values like this:
void operator()(const boost::system::error_code &ec= boost::system::error_code(), size_t bytes_transferred=0)
It can be called without an argument (for kick-off), with a single error_code (from async_wait) or with two argiments (from async_read).
Yes, that's the method the OP is currently using. It requires using a coroutine or other state to determine which "step" you're up to, whereas with separate overloads this is inherent in which method is being called. Neither approach is necessarily "better" than the other; it depends what you're doing in there as to which one ends up being more readable.