Closed ashtum closed 5 days ago
There are more cases where default completion token cause ambiguous overloads [source:https://stackoverflow.com/a/78499786/85371]
This minimal example shows two side-by-side (one of which is the async_connect
from the first issue comment)
#include <boost/asio.hpp>
#include <boost/core/ignore_unused.hpp>
namespace asio = boost::asio;
using asio::ip::tcp;
int main() {
auto x = asio::system_executor{};
auto r = asio::deferred.as_default_on(tcp::resolver{x});
auto s = asio::deferred.as_default_on(tcp::socket{x});
asio::streambuf b;
using Token = asio::default_completion_token_t<decltype(s)::executor_type>;
// auto op1 = asio::async_connect(s, r.resolve("", "8989"), Token());// BROKEN
auto op1 = asio::async_connect(s, r.resolve("", "8989")); // Workaround
// but conversely:
// auto op2 = asio::async_read(s, b, asio::transfer_all()); // BROKEN
auto op2 = asio::async_read(s, b, asio::transfer_all(), Token()); // Workaround
boost::ignore_unused(op1, op2);
}
Technically, the additional cases were fixed in some subsequent commits (ec5eee84cfd647 to compile my examples), I can confirm the fix is Boost Asio's master
branch meaning it will be in the next Boost release :tada:
When using an executor with a default completion token type, calls to
asio::async_connect
become ambiguous because the unconstrainedConnectCondition
parameter matches the passed completion token.I believe constraining the
ConnectCondition
can fix the issue.https://godbolt.org/z/aqxns58n5