MRE with gcc 13.1.1 / clang 15.0.7 and asio 1.28.0:
#include <asio.hpp>
struct foobar {
foobar() = delete;
foobar(const foobar &) = default;
foobar(foobar &&) = default;
foobar &operator=(const foobar &) = default;
foobar &operator=(foobar &&) = default;
};
asio::awaitable<foobar> async_foobar();
void not_ok(const asio::any_io_executor &ex) {
// I actually use `use_awaitable` in my code, using `detached` here to
// make it short as this issue is not relevant with completion token type.
asio::co_spawn(ex, async_foobar(), asio::detached);
}
This happens when I'm using ned14's outcome with asio, where outcome_v2::result<T, E, NVP> is never default constructible. I didn't find anywhere in the documentation indicating that co_spawn can only work on awaitable<T, E> where T is default constructible. I wonder if it's intentional or not, considering that awaitable<T, E> allows T being not default constructible and it works with simple co_await.
MRE with gcc 13.1.1 / clang 15.0.7 and asio 1.28.0:
This happens when I'm using ned14's outcome with asio, where
outcome_v2::result<T, E, NVP>
is never default constructible. I didn't find anywhere in the documentation indicating thatco_spawn
can only work onawaitable<T, E>
where T is default constructible. I wonder if it's intentional or not, considering thatawaitable<T, E>
allows T being not default constructible and it works with simpleco_await
.