More docs

This commit is contained in:
Simon Brand
2017-10-31 10:27:11 +00:00
parent 47b1ae09a3
commit 332297010c
2 changed files with 504 additions and 35 deletions

407
docs/index.md Normal file
View File

@@ -0,0 +1,407 @@
# Header file `expected.hpp`<a id="expected.hpp"></a>
<pre><code class="language-cpp">#define <a href='doc_expected.md#expected.hpp'>TL_EXPECTED_HPP</a>
#define <a href='doc_expected.md#expected.hpp'>TL_EXPECTED_GCC49</a>
#define <a href='doc_expected.md#expected.hpp'>TL_EXPECTED_NO_CONSTRR</a>
#define <a href='doc_expected.md#expected.hpp'>TL_EXPECTED_CXX14</a>
#define <a href='doc_expected.md#expected.hpp'>TL_IN_PLACE_MONOSTATE_DEFINED</a>
namespace <a href='doc_expected.md#expected.hpp'>tl</a>
{
class <a href='doc_expected.md#tl::monostate'>monostate</a>;
struct <a href='doc_expected.md#tl::in_place_t'>in_place_t</a>;
constexpr <a href='doc_expected.md#tl::in_place_t'>in_place_t{}</a> <a href='doc_expected.md#tl::in_place'>in_place</a>;
template &lt;class E&gt;
class <a href='doc_expected.md#tl::unexpected-E-'>unexpected</a>;
template &lt;class E&gt;
constexpr bool <a href='doc_expected.md#tl::operator==(constunexpected-E-&,constunexpected-E-&)'>operator==</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
template &lt;class E&gt;
constexpr bool <a href='doc_expected.md#tl::operator==(constunexpected-E-&,constunexpected-E-&)'>operator!=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
template &lt;class E&gt;
constexpr bool <a href='doc_expected.md#tl::operator==(constunexpected-E-&,constunexpected-E-&)'>operator&lt;</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
template &lt;class E&gt;
constexpr bool <a href='doc_expected.md#tl::operator==(constunexpected-E-&,constunexpected-E-&)'>operator&lt;=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
template &lt;class E&gt;
constexpr bool <a href='doc_expected.md#tl::operator==(constunexpected-E-&,constunexpected-E-&)'>operator&gt;</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
template &lt;class E&gt;
constexpr bool <a href='doc_expected.md#tl::operator==(constunexpected-E-&,constunexpected-E-&)'>operator&gt;=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
template &lt;class E&gt;
<a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a> <a href='doc_expected.md#tl::make_unexpected(E&&)'>make_unexpected</a>(E&amp;&amp; e);
struct <a href='doc_expected.md#tl::unexpect_t'>unexpect_t</a>;
constexpr <a href='doc_expected.md#tl::unexpect_t'>unexpect_t{}</a> <a href='doc_expected.md#tl::unexpect'>unexpect</a>;
template &lt;class E&gt;
class <a href='doc_expected.md#expected.hpp'>bad_expected_access</a>;
template &lt;class T, class E&gt;
class <a href='doc_expected.md#tl::expected-T,E-'>expected</a>;
template &lt;class T, class E, class U, class F&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator==</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, F&gt;</a>&amp; rhs);
template &lt;class T, class E, class U, class F&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator!=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, F&gt;</a>&amp; rhs);
template &lt;class T, class E, class U, class F&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, F&gt;</a>&amp; rhs);
template &lt;class T, class E, class U, class F&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, F&gt;</a>&amp; rhs);
template &lt;class T, class E, class U, class F&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, F&gt;</a>&amp; rhs);
template &lt;class T, class E, class U, class F&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, F&gt;</a>&amp; rhs);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator==</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const U&amp; v);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator==</a>(const U&amp; v, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator!=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const U&amp; v);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator!=</a>(const U&amp; v, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const U&amp; v);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;</a>(const U&amp; v, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const U&amp; v);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;=</a>(const U&amp; v, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const U&amp; v);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;</a>(const U&amp; v, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const U&amp; v);
template &lt;class T, class E, class U&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;=</a>(const U&amp; v, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator==</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator==</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator!=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator!=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&lt;=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e);
template &lt;class T, class E&gt;
constexpr bool <a href='doc_expected.md#expected.hpp'>operator&gt;=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; e, const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; x);
template &lt;class T, class E, 'hidden'&gt;
void <a href='doc_expected.md#expected.hpp'>swap</a>(<a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; lhs, <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;T, E&gt;</a>&amp; rhs) noexcept(noexcept(lhs.swap(rhs)));
}</code></pre>
## Class `tl::monostate`<a id="tl::monostate"></a>
<pre><code class="language-cpp">class monostate
{
};</code></pre>
Used to represent an expected with no data
## Struct `tl::in_place_t`<a id="tl::in_place_t"></a>
<pre><code class="language-cpp">struct in_place_t
{
<a href='doc_expected.md#tl::in_place_t'>in_place_t</a>() = default;
};</code></pre>
A tag type to tell expected to construct its value in-place
## Variable `tl::in_place`<a id="tl::in_place"></a>
<pre><code class="language-cpp">constexpr <a href='doc_expected.md#tl::in_place_t'>in_place_t{}</a> in_place;</code></pre>
A tag to tell expected to construct its value in-place
## Class template `tl::unexpected`<a id="tl::unexpected-E-"></a>
<pre><code class="language-cpp">template &lt;class E&gt;
class unexpected
{
public:
<a href='doc_expected.md#tl::unexpected-E-'>unexpected</a>() = delete;
constexpr <a href='doc_expected.md#tl::unexpected-E-'>unexpected</a>(const E&amp; e);
constexpr <a href='doc_expected.md#tl::unexpected-E-'>unexpected</a>(E&amp;&amp; e);
constexpr const E&amp; <a href='doc_expected.md#tl::unexpected-E-::value()const&'>value</a>() const &amp;;
constexpr E&amp; <a href='doc_expected.md#tl::unexpected-E-::value()const&'>value</a>() &amp;;
constexpr E&amp;&amp; <a href='doc_expected.md#tl::unexpected-E-::value()const&'>value</a>() &amp;&amp;;
};</code></pre>
Used as a wrapper to store the unexpected value
### Function `tl::unexpected::value`<a id="tl::unexpected-E-::value()const&"></a>
<pre><code class="language-cpp">(1) constexpr const E&amp; value() const &amp;;
(2) constexpr E&amp; value() &amp;;
(3) constexpr E&amp;&amp; value() &amp;&amp;;</code></pre>
*Returns*: the contained value
-----
## Comparison operator `tl::operator==`<a id="tl::operator==(constunexpected-E-&,constunexpected-E-&)"></a>
<pre><code class="language-cpp">(1) template &lt;class E&gt;
constexpr bool operator==(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
(2) template &lt;class E&gt;
constexpr bool operator!=(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
(3) template &lt;class E&gt;
constexpr bool operator&lt;(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
(4) template &lt;class E&gt;
constexpr bool operator&lt;=(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
(5) template &lt;class E&gt;
constexpr bool operator&gt;(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);
(6) template &lt;class E&gt;
constexpr bool operator&gt;=(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; lhs, const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>&amp; rhs);</code></pre>
Compares two unexpected objects
Simply compares lhs.value() to rhs.value()
## Function template `tl::make_unexpected`<a id="tl::make_unexpected(E&&)"></a>
<pre><code class="language-cpp">template &lt;class E&gt;
<a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a> make_unexpected(E&amp;&amp; e);</code></pre>
Create an `unexpected` from `e`, deducing the return type
*Example:* auto e1 = tl::make\_unexpected(42); unexpected\<int\> e2 (42); //same semantics
## Struct `tl::unexpect_t`<a id="tl::unexpect_t"></a>
<pre><code class="language-cpp">struct unexpect_t
{
<a href='doc_expected.md#tl::unexpect_t'>unexpect_t</a>() = default;
};</code></pre>
A tag type to tell expected to construct the unexpected value
## Variable `tl::unexpect`<a id="tl::unexpect"></a>
<pre><code class="language-cpp">constexpr <a href='doc_expected.md#tl::unexpect_t'>unexpect_t{}</a> unexpect;</code></pre>
A tag to tell expected to construct the unexpected value
## Class template `tl::expected`<a id="tl::expected-T,E-"></a>
<pre><code class="language-cpp">template &lt;class T, class E&gt;
class expected
{
public:
using <a href='doc_expected.md#tl::expected-T,E-'>value_type</a> = T;
using <a href='doc_expected.md#tl::expected-T,E-'>error_type</a> = E;
using <a href='doc_expected.md#tl::expected-T,E-'>unexpected_type</a> = <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;E&gt;</a>;
template &lt;class F&gt;
'hidden' <a href='doc_expected.md#tl::expected-T,E-::and_then(F&&)&'>and_then</a>(F&amp;&amp; f) &amp;;
template &lt;class F&gt;
constexpr auto and_then(F &amp;&amp;f) &amp;&amp;;
template &lt;class F&gt;
constexpr auto and_then(F &amp;&amp;f) const &amp;;
template &lt;class F&gt; constexpr auto map(F &amp;&amp;f) &amp;;
template &lt;class F&gt; constexpr auto map(F &amp;&amp;f) &amp;&amp;;
template &lt;class F&gt; constexpr auto map(F &amp;&amp;f) const &amp;;
template &lt;class F&gt; constexpr auto map_error(F &amp;&amp;f) &amp;;
template &lt;class F&gt; constexpr auto map_error(F &amp;&amp;f) &amp;&amp;;
template &lt;class F&gt; constexpr auto map_error(F &amp;&amp;f) const &amp;;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>() = default;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; rhs) = default;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(<a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp;&amp; rhs) = default;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator=</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; rhs) = default;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator=</a>(<a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp;&amp; rhs) = default;
template &lt;class ... Args, 'hidden' ... = nullptr&gt;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(<a href='doc_expected.md#tl::in_place_t'>in_place_t</a>, Args&amp;&amp;... args);
template &lt;class U, class ... Args, 'hidden' ... = nullptr&gt;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(<a href='doc_expected.md#tl::in_place_t'>in_place_t</a>, <a href='http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=std::initializer_list%3cU%3e'>std::initializer_list&lt;U&gt;</a> il, Args&amp;&amp;... args);
EXPLICIT constexpr expected(const unexpected&lt;G&gt; &amp;e);
EXPLICIT constexpr expected(unexpected&lt;G&gt; &amp;&amp;e);
template &lt;class ... Args, 'hidden' ... = nullptr&gt;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(<a href='doc_expected.md#tl::unexpect_t'>unexpect_t</a>, Args&amp;&amp;... args);
template &lt;class U, class G, 'hidden'&gt;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(const <a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, G&gt;</a>&amp; rhs);
template &lt;class U, class G, 'hidden'&gt;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(<a href='doc_expected.md#tl::expected-T,E-'>expected&lt;U, G&gt;</a>&amp;&amp; rhs);
template &lt;class U = T, 'hidden'&gt;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>expected</a>(U&amp;&amp; v);
template &lt;class U = T, 'hidden', 'hidden'&gt;
<a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator=</a>(U&amp;&amp; v);
template &lt;class G = E, 'hidden'&gt;
<a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator=</a>(const <a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;G&gt;</a>&amp; rhs);
template &lt;class G = E, 'hidden'&gt;
<a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator=</a>(<a href='doc_expected.md#tl::unexpected-E-'>unexpected&lt;G&gt;</a>&amp;&amp; rhs) noexcept;
template &lt;class ... Args, 'hidden' ... = nullptr&gt;
void <a href='doc_expected.md#tl::expected-T,E-'>emplace</a>(Args&amp;&amp;... args);
template &lt;class U, class ... Args, 'hidden' ... = nullptr&gt;
void <a href='doc_expected.md#tl::expected-T,E-'>emplace</a>(<a href='http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=std::initializer_list%3cU%3e'>std::initializer_list&lt;U&gt;</a> il, Args&amp;&amp;... args);
void <a href='doc_expected.md#tl::expected-T,E-'>swap</a>(<a href='doc_expected.md#tl::expected-T,E-'>expected</a>&amp; rhs) noexcept(std::is_nothrow_move_constructible&lt;T&gt;::value&amp;&amp;noexcept(swap(std::declval&lt;T&amp;&gt;(), std::declval&lt;T&amp;&gt;()))&amp;&amp;std::is_nothrow_move_constructible&lt;E&gt;::value&amp;&amp;noexcept(swap(std::declval&lt;E&amp;&gt;(), std::declval&lt;E&amp;&gt;())));
constexpr const T* <a href='doc_expected.md#tl::expected-T,E-'>operator-&gt;</a>() const;
constexpr T* <a href='doc_expected.md#tl::expected-T,E-'>operator-&gt;</a>();
constexpr const T&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator*</a>() const &amp;;
constexpr T&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator*</a>() &amp;;
constexpr const T&amp;&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator*</a>() const &amp;&amp;;
constexpr T&amp;&amp; <a href='doc_expected.md#tl::expected-T,E-'>operator*</a>() &amp;&amp;;
constexpr <a href='doc_expected.md#tl::expected-T,E-'>operator bool</a>() const noexcept;
constexpr bool <a href='doc_expected.md#tl::expected-T,E-'>has_value</a>() const noexcept;
constexpr const T&amp; <a href='doc_expected.md#tl::expected-T,E-'>value</a>() const &amp;;
constexpr T&amp; <a href='doc_expected.md#tl::expected-T,E-'>value</a>() &amp;;
constexpr const T&amp;&amp; <a href='doc_expected.md#tl::expected-T,E-'>value</a>() const &amp;&amp;;
constexpr T&amp;&amp; <a href='doc_expected.md#tl::expected-T,E-'>value</a>() &amp;&amp;;
constexpr const E&amp; <a href='doc_expected.md#tl::expected-T,E-'>error</a>() const &amp;;
constexpr E&amp; <a href='doc_expected.md#tl::expected-T,E-'>error</a>() &amp;;
constexpr const E&amp;&amp; <a href='doc_expected.md#tl::expected-T,E-'>error</a>() const &amp;&amp;;
constexpr E&amp;&amp; <a href='doc_expected.md#tl::expected-T,E-'>error</a>() &amp;&amp;;
template &lt;class U&gt;
constexpr T <a href='doc_expected.md#tl::expected-T,E-'>value_or</a>(U&amp;&amp; v) const &amp;;
template &lt;class U&gt;
T <a href='doc_expected.md#tl::expected-T,E-'>value_or</a>(U&amp;&amp; v) &amp;&amp;;
};</code></pre>
An `expected<T, E>` object is an object that contains the storage for another object and manages the lifetime of this contained object `T`. Alternatively it could contain the storage for another unexpected object `E`. The contained object may not be initialized after the expected object has been initialized, and may not be destroyed before the expected object has been destroyed. The initialization state of the contained object is tracked by the expected object.
### Function template `tl::expected::and_then`<a id="tl::expected-T,E-::and_then(F&&)&"></a>
<pre><code class="language-cpp">(1) template &lt;class F&gt;
'hidden' and_then(F&amp;&amp; f) &amp;;
(2) template &lt;class F&gt;
constexpr auto and_then(F &amp;&amp;f) &amp;&amp;;
(3) template &lt;class F&gt;
constexpr auto and_then(F &amp;&amp;f) const &amp;;</code></pre>
Carries out some operation which returns an optional on the stored object if there is one. \\requires `std::invoke(std::forward<F>(f), value())` returns a `std::optional<U>` for some `U`. \\returns Let `U` be the result of `std::invoke(std::forward<F>(f), value())`. Returns a `std::optional<U>`. The return value is empty if `*this` is empty, otherwise the return value of `std::invoke(std::forward<F>(f), value())` is returned. \\group and\_then \\synopsis template \<class F\>\\nconstexpr auto and\_then(F &\&f) &;
### Function template `tl::expected::map`<a id="tl::expected-T,E-::map(F&&)&"></a>
<pre><code class="language-cpp">(1) template &lt;class F&gt; constexpr auto map(F &amp;&amp;f) &amp;;
(2) template &lt;class F&gt; constexpr auto map(F &amp;&amp;f) &amp;&amp;;
(3) template &lt;class F&gt; constexpr auto map(F &amp;&amp;f) const &amp;;</code></pre>
Carries out some operation on the stored object if there is one.
*Returns*: Let `U` be the result of `std::invoke(std::forward<F>(f), value())`. Returns a `std::expected<U,E>`. If `*this` is unexpected, the result is `*this`, otherwise an `expected<U,E>` is constructed from the return value of `std::invoke(std::forward<F>(f), value())` and is returned.
### Function template `tl::expected::map_error`<a id="tl::expected-T,E-::map_error(F&&)&"></a>
<pre><code class="language-cpp">(1) template &lt;class F&gt; constexpr auto map_error(F &amp;&amp;f) &amp;;
(2) template &lt;class F&gt; constexpr auto map_error(F &amp;&amp;f) &amp;&amp;;
(3) template &lt;class F&gt; constexpr auto map_error(F &amp;&amp;f) const &amp;;</code></pre>
Carries out some operation on the stored unexpected object if there is one.
*Returns*: Let `U` be the result of `std::invoke(std::forward<F>(f), value())`. Returns a `std::expected<T,U>`. If `*this` has an expected value, the result is `*this`, otherwise an `expected<T,U>` is constructed from `make_unexpected(std::invoke(std::forward<F>(f), value()))` and is returned.
### Function template `tl::expected::expected`<a id="tl::expected-T,E-::expected(constunexpected-G-&)"></a>
<pre><code class="language-cpp">(1) EXPLICIT constexpr expected(const unexpected&lt;G&gt; &amp;e);
(2) EXPLICIT constexpr expected(unexpected&lt;G&gt; &amp;&amp;e);</code></pre>
-----
-----

View File

@@ -139,8 +139,8 @@ public:
constexpr E &value() & { return m_val; } constexpr E &value() & { return m_val; }
/// \group unexpected_value /// \group unexpected_value
constexpr E &&value() && { return std::move(m_val); } constexpr E &&value() && { return std::move(m_val); }
/// \group unexpected_value /// \exclude
constexpr E const &&value() const && { return std::move(m_val); } constexpr const E &&value() const && { return std::move(m_val); }
private: private:
E m_val; E m_val;
@@ -374,7 +374,8 @@ template <class T, class E> struct expected_storage_base<T, E, false, true> {
// expected_copy_move_base is used to conditionally delete the move/copy // expected_copy_move_base is used to conditionally delete the move/copy
// constructors/assignment operators depending on the traits of T and E. // constructors/assignment operators depending on the traits of T and E.
// TODO these could be reduced a bit by splitting construction and assignment into different bases // TODO these could be reduced a bit by splitting construction and assignment
// into different bases
template < template <
class T, class E, class T, class E,
bool EnableCopy = (std::is_copy_constructible<T>::value && bool EnableCopy = (std::is_copy_constructible<T>::value &&
@@ -869,8 +870,7 @@ public:
"F must return an expected"); "F must return an expected");
return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this))
: result(unexpect, std:: : result(unexpect, std::move(this->error()));
: move(this->error()));
} }
#endif #endif
@@ -937,32 +937,44 @@ public:
!defined(TL_EXPECTED_GCC54) !defined(TL_EXPECTED_GCC54)
/// \brief Carries out some operation on the stored object if there is one. /// \brief Carries out some operation on the stored object if there is one.
/// \returns Let `U` be the result of `std::invoke(std::forward<F>(f), /// \returns Let `U` be the result of `std::invoke(std::forward<F>(f),
/// value())`. Returns a `std::expected<U>`. The return value is empty if /// value())`. Returns a `std::expected<U,E>`. If `*this` is unexpected, the
/// `*this` is empty, otherwise an `expected<U>` is constructed from the /// result is `*this`, otherwise an `expected<U,E>` is constructed from the
/// return value of `std::invoke(std::forward<F>(f), value())` and is /// return value of `std::invoke(std::forward<F>(f), value())` and is
/// returned. \group map \synopsis template <class F> auto map(F &&f) &; /// returned.
///
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) &;
template <class F> TL_EXPECTED_11_CONSTEXPR auto map(F &&f) & { template <class F> TL_EXPECTED_11_CONSTEXPR auto map(F &&f) & {
return map_impl(*this, std::forward<F>(f)); return map_impl(*this, std::forward<F>(f));
} }
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) &&;
template <class F> TL_EXPECTED_11_CONSTEXPR auto map(F &&f) && { template <class F> TL_EXPECTED_11_CONSTEXPR auto map(F &&f) && {
return map_impl(std::move(*this), std::forward<F>(f)); return map_impl(std::move(*this), std::forward<F>(f));
} }
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) const &;
template <class F> constexpr auto map(F &&f) const & { template <class F> constexpr auto map(F &&f) const & {
return map_impl(*this, std::forward<F>(f)); return map_impl(*this, std::forward<F>(f));
} }
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) const &&;
template <class F> constexpr auto map(F &&f) const && { template <class F> constexpr auto map(F &&f) const && {
return map_impl(std::move(*this), std::forward<F>(f)); return map_impl(std::move(*this), std::forward<F>(f));
} }
#else #else
/// \brief Carries out some operation on the stored object if there is one. /// \brief Carries out some operation on the stored object if there is one.
/// \returns Let `U` be the result of `std::invoke(std::forward<F>(f), /// \returns Let `U` be the result of `std::invoke(std::forward<F>(f),
/// value())`. Returns a `std::expected<U>`. The return value is empty if /// value())`. Returns a `std::expected<U,E>`. If `*this` is unexpected, the
/// `*this` is empty, otherwise an `expected<U>` is constructed from the /// result is `*this`, otherwise an `expected<U,E>` is constructed from the
/// return value of `std::invoke(std::forward<F>(f), value())` and is /// return value of `std::invoke(std::forward<F>(f), value())` and is
/// returned. \group map \synopsis template <class F> auto map(F &&f) &; /// returned.
///
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) &;
template <class F> template <class F>
TL_EXPECTED_11_CONSTEXPR decltype(map_impl(std::declval<expected &>(), TL_EXPECTED_11_CONSTEXPR decltype(map_impl(std::declval<expected &>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -970,13 +982,17 @@ public:
return map_impl(*this, std::forward<F>(f)); return map_impl(*this, std::forward<F>(f));
} }
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) &&;
template <class F> template <class F>
TL_EXPECTED_11_CONSTEXPR decltype(map_impl(std::declval<expected &&>(), TL_EXPECTED_11_CONSTEXPR decltype(map_impl(std::declval<expected &>(),
std::declval<F &&>())) std::declval<F &&>()))
map(F &&f) && { map(F &&f) && {
return map_impl(std::move(*this), std::forward<F>(f)); return map_impl(std::move(*this), std::forward<F>(f));
} }
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) const &;
template <class F> template <class F>
constexpr decltype(map_impl(std::declval<const expected &>(), constexpr decltype(map_impl(std::declval<const expected &>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -985,6 +1001,8 @@ public:
} }
#ifndef TL_EXPECTED_NO_CONSTRR #ifndef TL_EXPECTED_NO_CONSTRR
/// \group map
/// \synopsis template <class F> constexpr auto map(F &&f) const &&;
template <class F> template <class F>
constexpr decltype(map_impl(std::declval<const expected &&>(), constexpr decltype(map_impl(std::declval<const expected &&>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -996,36 +1014,48 @@ public:
#if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \
!defined(TL_EXPECTED_GCC54) !defined(TL_EXPECTED_GCC54)
/// \brief Carries out some operation on the stored object if there is one. /// \brief Carries out some operation on the stored unexpected object if there
/// is one.
/// \returns Let `U` be the result of `std::invoke(std::forward<F>(f), /// \returns Let `U` be the result of `std::invoke(std::forward<F>(f),
/// value())`. Returns a `std::expected<U>`. The return value is empty if /// value())`. Returns a `std::expected<T,U>`. If `*this` has an expected
/// `*this` is empty, otherwise an `expected<U>` is constructed from the /// value, the result is `*this`, otherwise an `expected<T,U>` is constructed
/// return value of `std::invoke(std::forward<F>(f), value())` and is /// from `make_unexpected(std::invoke(std::forward<F>(f), value()))` and is
/// returned. \group map_error \synopsis template <class F> auto map_error(F /// returned.
/// &&f) &; ///
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) &;
template <class F> TL_EXPECTED_11_CONSTEXPR auto map_error(F &&f) & { template <class F> TL_EXPECTED_11_CONSTEXPR auto map_error(F &&f) & {
return map_error_impl(*this, std::forward<F>(f)); return map_error_impl(*this, std::forward<F>(f));
} }
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) &&;
template <class F> TL_EXPECTED_11_CONSTEXPR auto map_error(F &&f) && { template <class F> TL_EXPECTED_11_CONSTEXPR auto map_error(F &&f) && {
return map_error_impl(std::move(*this), std::forward<F>(f)); return map_error_impl(std::move(*this), std::forward<F>(f));
} }
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) const &;
template <class F> constexpr auto map_error(F &&f) const & { template <class F> constexpr auto map_error(F &&f) const & {
return map_error_impl(*this, std::forward<F>(f)); return map_error_impl(*this, std::forward<F>(f));
} }
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) const &&;
template <class F> constexpr auto map_error(F &&f) const && { template <class F> constexpr auto map_error(F &&f) const && {
return map_error_impl(std::move(*this), std::forward<F>(f)); return map_error_impl(std::move(*this), std::forward<F>(f));
} }
#else #else
/// \brief Carries out some operation on the stored object if there is one. /// \brief Carries out some operation on the stored unexpected object if there
/// is one.
/// \returns Let `U` be the result of `std::invoke(std::forward<F>(f), /// \returns Let `U` be the result of `std::invoke(std::forward<F>(f),
/// value())`. Returns a `std::expected<U>`. The return value is empty if /// value())`. Returns a `std::expected<T,U>`. If `*this` has an expected
/// `*this` is empty, otherwise an `expected<U>` is constructed from the /// value, the result is `*this`, otherwise an `expected<T,U>` is constructed
/// return value of `std::invoke(std::forward<F>(f), value())` and is /// from `make_unexpected(std::invoke(std::forward<F>(f), value()))` and is
/// returned. \group map_error \synopsis template <class F> auto map_error(F /// returned.
/// &&f) &; ///
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) &;
template <class F> template <class F>
TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected &>(), TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected &>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -1033,6 +1063,8 @@ public:
return map_error_impl(*this, std::forward<F>(f)); return map_error_impl(*this, std::forward<F>(f));
} }
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) &&;
template <class F> template <class F>
TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected &&>(), TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected &&>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -1040,6 +1072,8 @@ public:
return map_error_impl(std::move(*this), std::forward<F>(f)); return map_error_impl(std::move(*this), std::forward<F>(f));
} }
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) const &;
template <class F> template <class F>
constexpr decltype(map_error_impl(std::declval<const expected &>(), constexpr decltype(map_error_impl(std::declval<const expected &>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -1048,6 +1082,8 @@ public:
} }
#ifndef TL_EXPECTED_NO_CONSTRR #ifndef TL_EXPECTED_NO_CONSTRR
/// \group map_error
/// \synopsis template <class F> constexpr auto map_error(F &&f) const &&;
template <class F> template <class F>
constexpr decltype(map_error_impl(std::declval<const expected &&>(), constexpr decltype(map_error_impl(std::declval<const expected &&>(),
std::declval<F &&>())) std::declval<F &&>()))
@@ -1077,15 +1113,18 @@ public:
: impl_base(in_place, il, std::forward<Args>(args)...), : impl_base(in_place, il, std::forward<Args>(args)...),
ctor_base(detail::default_constructor_tag{}) {} ctor_base(detail::default_constructor_tag{}) {}
/// \group unexpected_ctor
/// \synopsis EXPLICIT constexpr expected(const unexpected<G> &e);
template <class G = E, template <class G = E,
detail::enable_if_t<std::is_constructible<E, const G &>::value> * = detail::enable_if_t<std::is_constructible<E, const G &>::value> * =
nullptr, nullptr,
detail::enable_if_t<!std::is_convertible<const G &, E>::value> * = detail::enable_if_t<!std::is_convertible<const G &, E>::value> * =
nullptr> nullptr>
explicit constexpr expected(unexpected<G> const &e) explicit constexpr expected(const unexpected<G> &e)
: impl_base(unexpect, e.value()), : impl_base(unexpect, e.value()),
ctor_base(detail::default_constructor_tag{}) {} ctor_base(detail::default_constructor_tag{}) {}
/// \exclude
template < template <
class G = E, class G = E,
detail::enable_if_t<std::is_constructible<E, const G &>::value> * = detail::enable_if_t<std::is_constructible<E, const G &>::value> * =
@@ -1095,6 +1134,8 @@ public:
: impl_base(unexpect, e.value()), : impl_base(unexpect, e.value()),
ctor_base(detail::default_constructor_tag{}) {} ctor_base(detail::default_constructor_tag{}) {}
/// \group unexpected_ctor
/// \synopsis EXPLICIT constexpr expected(unexpected<G> &&e);
template < template <
class G = E, class G = E,
detail::enable_if_t<std::is_constructible<E, G &&>::value> * = nullptr, detail::enable_if_t<std::is_constructible<E, G &&>::value> * = nullptr,
@@ -1104,6 +1145,7 @@ public:
: impl_base(unexpect, std::move(e.value())), : impl_base(unexpect, std::move(e.value())),
ctor_base(detail::default_constructor_tag{}) {} ctor_base(detail::default_constructor_tag{}) {}
/// \exclude
template < template <
class G = E, class G = E,
detail::enable_if_t<std::is_constructible<E, G &&>::value> * = nullptr, detail::enable_if_t<std::is_constructible<E, G &&>::value> * = nullptr,
@@ -1120,6 +1162,7 @@ public:
: impl_base(unexpect, std::forward<Args>(args)...), : impl_base(unexpect, std::forward<Args>(args)...),
ctor_base(detail::default_constructor_tag{}) {} ctor_base(detail::default_constructor_tag{}) {}
/// \exclude
template <class U, class... Args, template <class U, class... Args,
detail::enable_if_t<std::is_constructible< detail::enable_if_t<std::is_constructible<
E, std::initializer_list<U> &, Args &&...>::value> * = nullptr> E, std::initializer_list<U> &, Args &&...>::value> * = nullptr>
@@ -1130,8 +1173,8 @@ public:
// TODO SFINAE // TODO SFINAE
template <class U, class G, template <class U, class G,
detail::enable_if_t<(!std::is_convertible<U const &, T>::value || detail::enable_if_t<!(std::is_convertible<U const &, T>::value &&
!std::is_convertible<G const &, E>::value)> * = std::is_convertible<G const &, E>::value)> * =
nullptr> nullptr>
explicit constexpr expected(const expected<U, G> &rhs) explicit constexpr expected(const expected<U, G> &rhs)
: ctor_base(detail::default_constructor_tag{}) { : ctor_base(detail::default_constructor_tag{}) {
@@ -1143,11 +1186,12 @@ public:
} }
// TODO SFINAE // TODO SFINAE
template < /// \exclude
class U, class G, template <class U, class G,
detail::enable_if_t<(!std::is_convertible<U &&, T>::value || detail::enable_if_t<(std::is_convertible<U const &, T>::value &&
!std::is_convertible<G &&, E>::value)> * = nullptr> std::is_convertible<G const &, E>::value)> * =
explicit constexpr expected(const expected<U, G> &rhs) nullptr>
constexpr expected(const expected<U, G> &rhs)
: ctor_base(detail::default_constructor_tag{}) { : ctor_base(detail::default_constructor_tag{}) {
if (rhs.has_value()) { if (rhs.has_value()) {
::new (valptr()) T(*rhs); ::new (valptr()) T(*rhs);
@@ -1159,7 +1203,22 @@ public:
// TODO SFINAE // TODO SFINAE
template < template <
class U, class G, class U, class G,
detail::enable_if_t<(std::is_convertible<U &&, T>::value || detail::enable_if_t<!(std::is_convertible<U &&, T>::value &&
std::is_convertible<G &&, E>::value)> * = nullptr>
explicit constexpr expected(expected<U, G> &&rhs)
: ctor_base(detail::default_constructor_tag{}) {
if (rhs.has_value()) {
::new (valptr()) T(std::move(*rhs));
} else {
::new (errptr()) unexpected_type(unexpected<E>(std::move(rhs.error())));
}
}
// TODO SFINAE
/// \exclude
template <
class U, class G,
detail::enable_if_t<(std::is_convertible<U &&, T>::value &&
std::is_convertible<G &&, E>::value)> * = nullptr> std::is_convertible<G &&, E>::value)> * = nullptr>
constexpr expected(expected<U, G> &&rhs) constexpr expected(expected<U, G> &&rhs)
: ctor_base(detail::default_constructor_tag{}) { : ctor_base(detail::default_constructor_tag{}) {
@@ -1176,6 +1235,7 @@ public:
explicit constexpr expected(U &&v) : expected(in_place, std::forward<U>(v)) {} explicit constexpr expected(U &&v) : expected(in_place, std::forward<U>(v)) {}
// TODO SFINAE // TODO SFINAE
/// \exclude
template <class U = T, detail::enable_if_t< template <class U = T, detail::enable_if_t<
std::is_convertible<U &&, T>::value> * = nullptr> std::is_convertible<U &&, T>::value> * = nullptr>
constexpr expected(U &&v) : expected(in_place, std::forward<U>(v)) {} constexpr expected(U &&v) : expected(in_place, std::forward<U>(v)) {}
@@ -1203,6 +1263,7 @@ public:
return *this; return *this;
} }
/// \exclude
template < template <
class U = T, class U = T,
detail::enable_if_t< detail::enable_if_t<
@@ -1274,6 +1335,7 @@ public:
} }
} }
/// \exclude
template <class... Args, detail::enable_if_t<!std::is_nothrow_constructible< template <class... Args, detail::enable_if_t<!std::is_nothrow_constructible<
T, Args &&...>::value> * = nullptr> T, Args &&...>::value> * = nullptr>
void emplace(Args &&... args) { void emplace(Args &&... args) {
@@ -1307,6 +1369,7 @@ public:
} }
} }
/// \exclude
template <class U, class... Args, template <class U, class... Args,
detail::enable_if_t<!std::is_nothrow_constructible< detail::enable_if_t<!std::is_nothrow_constructible<
T, std::initializer_list<U> &, Args &&...>::value> * = nullptr> T, std::initializer_list<U> &, Args &&...>::value> * = nullptr>
@@ -1397,10 +1460,9 @@ public:
"T must be move-constructible and convertible to from U&&"); "T must be move-constructible and convertible to from U&&");
return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v)); return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
} }
private:
}; };
/// \exclude
namespace detail { namespace detail {
template <class Exp> using err_t = typename detail::decay_t<Exp>::error_type; template <class Exp> using err_t = typename detail::decay_t<Exp>::error_type;
template <class Exp, class Ret> using ret_t = expected<Ret, err_t<Exp>>; template <class Exp, class Ret> using ret_t = expected<Ret, err_t<Exp>>;