template<typename Mapper = detail::asio::map_default>
use_continuable_t struct
Type used as an ASIO completion token to specify an asynchronous operation that should return a continuable_
Template parameters | |
---|---|
Mapper | The token can be instantiated with a custom mapper for asio error codes which makes it possible to ignore errors or treat them as cancellation types. The mapper has the following form: struct my_mapper { constexpr my_mapper() noexcept {} /// Returns true when the error_code_t is a type which represents /// cancellation and bool is_cancellation(error_code_t const& /*ec*/) const noexcept { return false; } bool is_ignored(error_code_t const& /*ec*/) const noexcept { return false; } }; |
- Boost 1.70 or asio 1.13.0 is required for the async initiation
- Until boost 1.72 or asio 1.16.0 overhead through an additional type erasure is added. It is recommended to update to those versions.
The special static variable use_continuable can be appended to any (boost) asio function that accepts a callback to make it return a continuable_
#include <continuable/continuable.hpp> #include <continuable/external/asio.hpp> #include <asio.hpp> // ... asio::tcp::resolver resolver(...); resolver.async_resolve("127.0.0.1", "daytime", cti::use_continuable) .then([](asio::udp::resolver::iterator iterator) { // ... });