[ASIO] Need help reading the documentation

Hi Everyone, I need some help in reading the ASIO docs. I am looking at the following example from the docs https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/example/cpp17/coro... It calls one of the overloads of async_write in line co_await async_write(socket, boost::asio::buffer(data, n), use_awaitable); The reference section lists eight overloads: https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/async_wr... But it is still impossible for me to figure out which one it is. `use_awaitable` is documented as "completion token" in https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/use_awai... There is some mention of completion token at https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/asynchro... So I would expect the name `CompletionToken` to appear in the documentation of `async_write`. Am I missing something? Regards, &rzej;

On Thu, Dec 30, 2021 at 4:22 PM Andrzej Krzemienski via Boost
So I would expect the name `CompletionToken` to appear in the documentation of `async_write`. Am I missing something?
Yes. The overload is the first one: template< typename AsyncWriteStream, typename ConstBufferSequence, typename WriteHandler = DEFAULT> DEDUCED async_write( AsyncWriteStream & s, const ConstBufferSequence & buffers, WriteHandler && handler = DEFAULT, .... "WriteHandler" actually means "CompletionToken" in this context. I think it is for legacy reasons. In any event, all initiating functions follow the rules described here: https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/asynchro... Any time "handler" appears in an initiating function signature, it accepts a completion token for that argument. Beast follows this convention as well. I agree that the documentation needs work. Thanks
participants (2)
-
Andrzej Krzemienski
-
Vinnie Falco