...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Return a yield context that sets the specified error_code.
basic_yield_context operator[]( boost::system::error_code & ec) const;
By default, when a yield context is used with an asynchronous operation, a non-success error_code is converted to system_error and thrown. This operator may be used to specify an error_code object that should instead be set with the asynchronous operation's result. For example:
template <typename Executor> void my_coroutine(basic_yield_context<Executor> yield) { ... std::size_t n = my_socket.async_read_some(buffer, yield[ec]); if (ec) { // An error occurred. } ... }