с корутинами в boost asio ?
Возможно, чтобы твой классец можно было поюзать со следущим кодом ''' #include <boost/asio/io_context.hpp> #include <boost/asio/co_spawn.hpp> #include <boost/asio/use_awaitable.hpp> int main() { asio::io_context ioContext; asio::co_spawn(ioContext, []() -> asio::awaitable<void> { YourClassName your_class_instance; auto result = co_await your_class_instance; for (const auto& smth : result) { std::cout << smth << std::endl; } }, asio::use_awaitable); ioContext.run(); return 0; } ''' твой класс должен реализовывать два метода: auto await_suspend(std::coroutine_handle<> handle) void await_resume() {} А так же версия буста должа быть совместима с std::coroutine_handle<> (с++20) Но что конкретно ты подразумеваешь под своими корутинами... и с чем они у тебя без примера mre совместимы
Сейчас кину mre
Мой класс такое реализует, но с корутинами boost::asio он не работает
Это не boost::asio, это boost::coroutine2
Я про boost::asio::awaitable
В Godbolt.org/z/hx1nvKafE есть буст 1_83й Посмотри командную строку И дополни своим mre
``` <source>:10:5: error: no matching member function for call to 'await_transform' co_await MREAwaitable{}; ^~~~~~~~ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:204:8: note: candidate function not viable: no known conversion from 'MREAwaitable' to 'this_coro::executor_t' for 1st argument auto await_transform(this_coro::executor_t) noexcept ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:230:8: note: candidate function not viable: no known conversion from 'MREAwaitable' to 'this_coro::cancellation_state_t' for 1st argument auto await_transform(this_coro::cancellation_state_t) noexcept ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:255:8: note: candidate function not viable: no known conversion from 'MREAwaitable' to 'this_coro::reset_cancellation_state_0_t' for 1st argument auto await_transform(this_coro::reset_cancellation_state_0_t) noexcept ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:344:8: note: candidate function not viable: no known conversion from 'MREAwaitable' to 'this_coro::throw_if_cancelled_0_t' for 1st argument auto await_transform(this_coro::throw_if_cancelled_0_t) ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:371:8: note: candidate function not viable: no known conversion from 'MREAwaitable' to 'this_coro::throw_if_cancelled_1_t' for 1st argument auto await_transform(this_coro::throw_if_cancelled_1_t throw_if_cancelled) ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:439:8: note: candidate function not viable: no known conversion from 'MREAwaitable' to 'detail::awaitable_thread_has_context_switched' for 1st argument auto await_transform(detail::awaitable_thread_has_context_switched) noexcept ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:169:8: note: candidate template ignored: could not match 'awaitable<T, any_io_executor>' against 'MREAwaitable' auto await_transform(awaitable<T, Executor> a) const ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:178:8: note: candidate template ignored: substitution failure [with Op = MREAwaitable]: no type named 'type' in 'boost::asio::constraint<false>' auto await_transform(Op&& op, ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:281:8: note: candidate template ignored: could not match 'this_coro::reset_cancellation_state_1_t<Filter>' against 'MREAwaitable' auto await_transform( ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:310:8: note: candidate template ignored: could not match 'this_coro::reset_cancellation_state_2_t<InFilter, OutFilter>' against 'MREAwaitable' auto await_transform( ^ /opt/compiler-explorer/libs/boost_1_83_0/boost/asio/impl/awaitable.hpp:402:8: note: candidate template ignored: substitution failure [with Function = MREAwaitable]: no type named 'type' in 'boost::asio::result_of<MREAwaitable (boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *)>' auto await_transform(Function f, ^ <source>:10:5: note: call to 'await_transform' implicitly required by 'co_await' here co_await MREAwaitable{}; ^ ~~~~~~~~~~~~~~ 1 error generated. ```
Ссылку кнопкой share!
Это куда
Господи. Справа сверху на годболте Share
Обсуждают сегодня