The asio library passes an error parameter in a lot of its examples, ie; http://think-async.com/Asio/asio-1.5.3/src/examples/echo/async_tcp_echo_server.cpp
What's the point of this parameter? Does asio actually populate this parameter with errors?
If I remove it from my handler function it compiles fine.
Actually, asio::placeholders::error
is equivalent to _1
Boost.Bind placeholder, so bind(&my_class::handler, this, asio::placeholders::error)
is just like bind(&my_class::handler, this, _1)
.
When this handler is being called by Boost.Asio completion-handler dispatcher, error_code
is passed as the 1st argument to this function.
However, you can always bind
a function that expects less arguments (in this case - zero) - when the binder gets invoked, any extra arguments are silently ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With