12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>value_or_error<T, U> - Boost.Outcome documentation</title>
- <link rel="stylesheet" href="../../css/boost.css" type="text/css">
- <meta name="generator" content="Hugo 0.52 with Boostdoc theme">
- <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
- <link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
- <body><div class="spirit-nav">
- <a accesskey="p" href="../../reference/converters.html"><img src="../../images/prev.png" alt="Prev"></a>
- <a accesskey="u" href="../../reference/converters.html"><img src="../../images/up.png" alt="Up"></a>
- <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/traits.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
- <div class="titlepage"><div><div><h1 style="clear: both"><code>value_or_error<T, U></code></h1></div></div></div>
- <p>A customisable converter of <a href="../../reference/concepts/valueorerror.html" class="api-reference"><code>ValueOrError<T, E></code></a>
- concept matching types. It must have the following form:</p>
- <div class="highlight"><pre class="chroma"><code class="language-c++" data-lang="c++"><span class="c1">// `T` will be the destination basic_result or basic_outcome.
- </span><span class="c1">// `U` will be the decayed form of the `ValueOrError<T, E>` concept matching input type.
- </span><span class="c1"></span><span class="k">template</span> <span class="o"><</span><span class="k">class</span><span class="err"> </span><span class="nc">T</span><span class="o">></span> <span class="k">struct</span> <span class="n">value_or_error</span><span class="o"><</span><span class="n">T</span><span class="p">,</span> <span class="n">U</span><span class="o">></span>
- <span class="p">{</span>
- <span class="c1">// False to indicate that this converter wants `basic_result`/`basic_outcome` to reject all other `basic_result`
- </span><span class="c1"></span> <span class="k">static</span> <span class="k">constexpr</span> <span class="kt">bool</span> <span class="n">enable_result_inputs</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span>
- <span class="c1">// False to indicate that this converter wants `basic_outcome` to reject all other `basic_outcome`
- </span><span class="c1"></span> <span class="k">static</span> <span class="k">constexpr</span> <span class="kt">bool</span> <span class="n">enable_outcome_inputs</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span>
-
- <span class="c1">// `X` will be the raw input form of `U`. It must return a `T`.
- </span><span class="c1"></span> <span class="k">template</span><span class="o"><</span><span class="k">class</span><span class="err"> </span><span class="nc">X</span><span class="o">></span> <span class="k">constexpr</span> <span class="n">T</span> <span class="k">operator</span><span class="p">()(</span><span class="n">X</span> <span class="o">&&</span><span class="n">v</span><span class="p">);</span>
- <span class="p">};</span>
- </code></pre></div>
- <p><em>Overridable</em>: By template specialisation into the <code>convert</code> namespace.</p>
- <p><em>Default</em>: If decayed <code>X</code> is same as <code>U</code>, concept <code>ValueOrError<U></code> matches, <code>X::value_type</code> is <code>void</code> or is explicitly constructible to <code>T::value_type</code>, and <code>X::error_type</code> is <code>void</code> or is explicitly constructible to <code>T::error_type</code>, then <code>operator()(X &&)</code> is made available.</p>
- <p><code>operator()(X &&v)</code> tests if <code>v.has_value()</code> is true, if so then a <code>T</code> with successful value is returned, else a <code>T</code> with unsuccessful value. If the input type was <code>void</code>, a default constructed value is used for either, else a move/copy construction from the source is performed.</p>
- <p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE::convert</code></p>
- <p><em>Header</em>: <code><boost/outcome/convert.hpp></code></p>
- </div><p><small>Last revised: December 15, 2018 at 17:49:37 UTC</small></p>
- <hr>
- <div class="spirit-nav">
- <a accesskey="p" href="../../reference/converters.html"><img src="../../images/prev.png" alt="Prev"></a>
- <a accesskey="u" href="../../reference/converters.html"><img src="../../images/up.png" alt="Up"></a>
- <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/traits.html"><img src="../../images/next.png" alt="Next"></a></div></body>
- </html>
|