AMDG On 03/29/2017 07:41 AM, Christopher Pisz via Boost-users wrote:
So, your whole method looks like:
void start_accept() { tcp_connection::pointer new_connection = tcp_connection::create(acceptor_.get_io_service());
std::function
callback = std::bind(&tcp_server::handle_accept, this, new_connection, std::placeholders::_1); acceptor_.async_accept(new_connection->socket(), callback); }
Seems to compile.
I really don't understand how we are binding arguments that the template parameters did not specify the std::function to take. Can I pass it a cow or a moose too and it won't care? As long as the callback takes a cow and a moose?
Exactly. The error_code is passed as _1. All the other arguments are saved by std::bind and std::function doesn't need to know about them at all.
I thought all arguments had to be specified in the template params.
All the arguments that are passed to the std::function need to be specified. async_accept ends up calling 'callback' with just an error_code. In Christ, Steven Watanabe