In this example, if I change this call with bind:
boost::asio::async_connect(
socket_,
results.begin(),
results.end(),
std::bind(
&session::on_connect,
shared_from_this(),
std::placeholders::_1));
To this:
auto self = shared_from_this();
boost::asio::async_connect(
socket_,
results.begin(),
results.end(),
[self](boost::system::error_code ec) {
self->on_connect(ec);
});
I get an assertion error:
boost/boost/asio/impl/connect.hpp:761: error: static_assert failed "IteratorConnectHandler type requirements not met"
BOOST_ASIO_ITERATOR_CONNECT_HANDLER_CHECK(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There's a comment there:
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a IteratorConnectHandler.
I personally don't prefer bind, and would like to change it to lambda. Am I doing it wrong or is this a little bug in boost::beast?
By the way changing to a lambda for on_resolve
works fine.