например, когда я пытался
Код: Выделить всё
boost::asio::co_spawn(ioc, [&co_redis]() -> boost::asio::awaitable {
auto r = co_await co_redis.command("setbit", "bmap", 100007, 0) ;
},boost::asio::detached);
Код: Выделить всё
No matching member function for call to 'await_transform'clang(ovl_no_viable_member_function_in_call)
awaitable.hpp(204, 8): Candidate function not viable: no known conversion from 'Awaiter' to 'this_coro::executor_t' for 1st argument
awaitable.hpp(230, 8): Candidate function not viable: no known conversion from 'Awaiter' to 'this_coro::cancellation_state_t' for 1st argument
awaitable.hpp(255, 8): Candidate function not viable: no known conversion from 'Awaiter' to 'this_coro::reset_cancellation_state_0_t' for 1st argument
awaitable.hpp(344, 8): Candidate function not viable: no known conversion from 'Awaiter' to 'this_coro::throw_if_cancelled_0_t' for 1st argument
awaitable.hpp(371, 8): Candidate function not viable: no known conversion from 'Awaiter' to 'this_coro::throw_if_cancelled_1_t' for 1st argument
awaitable.hpp(439, 8): Candidate function not viable: no known conversion from 'Awaiter' to 'detail::awaitable_thread_has_context_switched' for 1st argument
awaitable.hpp(169, 8): Candidate template ignored: could not match 'awaitable' against 'Awaiter'
awaitable.hpp(178, 8): Candidate template ignored: substitution failure [with Op = Awaiter]: no type named 'type' in 'boost::asio::constraint'
awaitable.hpp(281, 8): Candidate template ignored: could not match 'reset_cancellation_state_1_t' against 'Awaiter'
awaitable.hpp(310, 8): Candidate template ignored: could not match 'reset_cancellation_state_2_t' against 'Awaiter'
awaitable.hpp(402, 8): Candidate template ignored: substitution failure [with Function = Awaiter]: no type named 'type' in 'boost::asio::result_of'
Код: Выделить всё
template
class Awaiter {
public:
template
auto co_exec(CompletionToken &&token = {}) {
auto initiate = [this](Handler &&handler) mutable {
_async_redis->co_command_with_parser(
std::move(_cmd),
[this, handler = std::move(handler)](Future &&fut) mutable {
_result = std::move(fut);
if constexpr (std::is_same_v) {
handler();
} else {
handler(_result.get());
}
});
};
if constexpr (std::is_same_v) {
return boost::asio::async_initiate(
std::move(initiate), token);
} else {
return boost::asio::async_initiate(
std::move(initiate), token);
}
}
private:
friend class CoRedis;
Awaiter(AsyncRedis *r, FormattedCommand cmd)
: _async_redis(r), _cmd(std::move(cmd)) {}
AsyncRedis *_async_redis = nullptr;
FormattedCommand _cmd;
Future _result;
};
Итак, я хочу знать, есть ли какой-либо способ ее решения. напрямую используйте интерфейс сопрограммы с Boost.Asio, добавив внешний код.
Кроме того, почему исходный awaiter нельзя использовать с Boost.Asio?
Большое спасибо очень!
Подробнее здесь: https://stackoverflow.com/questions/790 ... boost-asio
Мобильная версия