1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 3<title>Returning Outcome types from Coroutines - Boost.Outcome documentation</title> 4<link rel="stylesheet" href="../../../css/boost.css" type="text/css"> 5<meta name="generator" content="Hugo 0.52 with Boostdoc theme"> 6<meta name="viewport" content="width=device-width,initial-scale=1.0"/> 7 8<link rel="icon" href="../../../images/favicon.ico" type="image/ico"/> 9<body><div class="spirit-nav"> 10<a accesskey="p" href="../../../tutorial/essential/coroutines/awaitables.html"><img src="../../../images/prev.png" alt="Prev"></a> 11 <a accesskey="u" href="../../../tutorial/essential/coroutines.html"><img src="../../../images/up.png" alt="Up"></a> 12 <a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../../tutorial/essential/coroutines/co_await.html"><img src="../../../images/next.png" alt="Next"></a></div><div id="content"> 13 <div class="titlepage"><div><div><h1 style="clear: both">Returning Outcome types from Coroutines</h1></div></div></div> 14 <p><code>eager<T></code> and <code>lazy<T></code> and their atomic editions are completely standard 15awaitables with no special behaviours, <strong>except</strong> if <code>T</code> is a <code>basic_result</code> 16or <code>basic_outcome</code>. In that situation, the following occurs:</p> 17 18<p>If the Coroutine throws a C++ exception which was not handled inside the Coroutine 19body, Outcome’s awaitable types try to convert it into a form which your Result or 20Outcome type being returned can transport. For example:</p> 21 22<ul> 23<li><p>If your Coroutine were returning a <code>result<T, std::exception_ptr></code>, an 24errored Result with a pointer to the exception thrown would be returned.</p></li> 25 26<li><p>If your Coroutine were returning a <code>result<T, std::error_code></code>, the 27exception ptr is passed to <a href="../../../reference/functions/error_from_exception.html" class="api-reference"><code>error_from_exception(</code></a> 28<code>)</code> to see 29if it can be matched to an equivalent <code>std::error_code</code>. If it can, an 30errored Result with the equivalent error code would be returned.</p></li> 31 32<li><p>If your Coroutine were returning an <code>outcome<T, std::error_code, std::exception_ptr></code>, 33an Errored Outcome is chosen preferentially to an Excepted Outcome.</p></li> 34 35<li><p>If your Coroutine were returning an <code>experimental::status_result<T, system_code></code>, 36because Experimental SG14 <code>system_code</code> can transport error codes or 37exception ptrs (or indeed <code>std::error_code</code>’s), an errored Result 38is returned.</p></li> 39</ul> 40 41 42 </div><p><small>Last revised: April 07, 2020 at 10:22:38 +0100</small></p> 43<hr> 44<div class="spirit-nav"> 45<a accesskey="p" href="../../../tutorial/essential/coroutines/awaitables.html"><img src="../../../images/prev.png" alt="Prev"></a> 46 <a accesskey="u" href="../../../tutorial/essential/coroutines.html"><img src="../../../images/up.png" alt="Up"></a> 47 <a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../../tutorial/essential/coroutines/co_await.html"><img src="../../../images/next.png" alt="Next"></a></div></body> 48</html> 49