structboost_1_1hana_1_1optional.html 104 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <!--
  2. Copyright Louis Dionne 2013-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. -->
  6. <!-- boost-no-inspect -->
  7. <!-- HTML header for doxygen 1.8.9.1-->
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  12. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  13. <meta name="generator" content="Doxygen 1.8.15"/>
  14. <title>Boost.Hana: boost::hana::optional&lt; T &gt; Struct Template Reference</title>
  15. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  16. <script type="text/javascript" src="jquery.js"></script>
  17. <script type="text/javascript" src="dynsections.js"></script>
  18. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  19. <script type="text/javascript" src="resize.js"></script>
  20. <script type="text/javascript" src="navtreedata.js"></script>
  21. <script type="text/javascript" src="navtree.js"></script>
  22. <script type="text/javascript">
  23. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  24. $(document).ready(initResizable);
  25. /* @license-end */</script>
  26. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  27. <script type="text/javascript" src="search/searchdata.js"></script>
  28. <script type="text/javascript" src="search/search.js"></script>
  29. <script type="text/javascript">
  30. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  31. $(document).ready(function() { init_search(); });
  32. /* @license-end */
  33. </script>
  34. <script type="text/x-mathjax-config">
  35. MathJax.Hub.Config({
  36. extensions: ["tex2jax.js"],
  37. jax: ["input/TeX","output/HTML-CSS"],
  38. });
  39. // Copyright Louis Dionne 2013-2017
  40. // Distributed under the Boost Software License, Version 1.0.
  41. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  42. MathJax.Hub.Config({
  43. "HTML-CSS": {
  44. linebreaks: {
  45. automatic: true,
  46. width: "75% container"
  47. }
  48. }
  49. });
  50. </script><script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
  51. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  52. <!-- Additional javascript for drawing charts. -->
  53. <script type="text/javascript" src="highcharts.js"></script>
  54. <script type="text/javascript" src="highcharts-data.js"></script>
  55. <script type="text/javascript" src="highcharts-exporting.js"></script>
  56. <script type="text/javascript" src="chart.js"></script>
  57. <script type="text/javascript" src="hana.js"></script>
  58. </head>
  59. <body>
  60. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  61. <div id="titlearea">
  62. <table cellspacing="0" cellpadding="0">
  63. <tbody>
  64. <tr style="height: 56px;">
  65. <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  66. <td style="padding-left: 0.5em;">
  67. <div id="projectname">Boost.Hana
  68. &#160;<span id="projectnumber">1.6.0</span>
  69. </div>
  70. <div id="projectbrief">Your standard library for metaprogramming</div>
  71. </td>
  72. <td> <div id="MSearchBox" class="MSearchBoxInactive">
  73. <span class="left">
  74. <img id="MSearchSelect" src="search/mag_sel.png"
  75. onmouseover="return searchBox.OnSearchSelectShow()"
  76. onmouseout="return searchBox.OnSearchSelectHide()"
  77. alt=""/>
  78. <input type="text" id="MSearchField" value="Search" accesskey="S"
  79. onfocus="searchBox.OnSearchFieldFocus(true)"
  80. onblur="searchBox.OnSearchFieldFocus(false)"
  81. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  82. </span><span class="right">
  83. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  84. </span>
  85. </div>
  86. </td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. </div>
  91. <!-- end header part -->
  92. <!-- Generated by Doxygen 1.8.15 -->
  93. <script type="text/javascript">
  94. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  95. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  96. /* @license-end */
  97. </script>
  98. </div><!-- top -->
  99. <div id="side-nav" class="ui-resizable side-nav-resizable">
  100. <div id="nav-tree">
  101. <div id="nav-tree-contents">
  102. <div id="nav-sync" class="sync"></div>
  103. </div>
  104. </div>
  105. <div id="splitbar" style="-moz-user-select:none;"
  106. class="ui-resizable-handle">
  107. </div>
  108. </div>
  109. <script type="text/javascript">
  110. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  111. $(document).ready(function(){initNavTree('structboost_1_1hana_1_1optional.html','');});
  112. /* @license-end */
  113. </script>
  114. <div id="doc-content">
  115. <!-- window showing the filter options -->
  116. <div id="MSearchSelectWindow"
  117. onmouseover="return searchBox.OnSearchSelectShow()"
  118. onmouseout="return searchBox.OnSearchSelectHide()"
  119. onkeydown="return searchBox.OnSearchSelectKey(event)">
  120. </div>
  121. <!-- iframe showing the search results (closed by default) -->
  122. <div id="MSearchResultsWindow">
  123. <iframe src="javascript:void(0)" frameborder="0"
  124. name="MSearchResults" id="MSearchResults">
  125. </iframe>
  126. </div>
  127. <div class="header">
  128. <div class="summary">
  129. <a href="#related">Synopsis of associated functions</a> &#124;
  130. <a href="#friends">Friends</a> &#124;
  131. <a href="#pub-methods">Public Member Functions</a> &#124;
  132. <a href="structboost_1_1hana_1_1optional-members.html">List of all members</a> </div>
  133. <div class="headertitle">
  134. <div class="title">boost::hana::optional&lt; T &gt; Struct Template Reference<div class="ingroups"><a class="el" href="group__group-datatypes.html">Data types</a></div></div> </div>
  135. </div><!--header-->
  136. <div class="contents">
  137. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  138. <div class="textblock"><h3>template&lt;typename ... T&gt;<br />
  139. struct boost::hana::optional&lt; T &gt;</h3>
  140. <p>Optional value whose optional-ness is known at compile-time. </p>
  141. <p>An <code>optional</code> either contains a value (represented as <code>just(x)</code>), or it is empty (represented as <code>nothing</code>). In essence, <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> is pretty much like a <code>boost::optional</code> or the upcoming <code>std::optional</code>, except for the fact that whether a <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> is empty or not is known at compile-time. This can be particularly useful for returning from a function that might fail, but whose reason for failing is not important. Of course, whether the function will fail has to be known at compile-time.</p>
  142. <p>This is really an important difference between <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> and <code>std::optional</code>. Unlike <code>std::optional&lt;T&gt;{}</code> and <code>std::optional&lt;T&gt;{x}</code> who share the same type (<code>std::optional&lt;T&gt;</code>), <code>hana::just(x)</code> and <code>hana::nothing</code> do not share the same type, since the state of the optional has to be known at compile-time. Hence, whether a <code>hana::just</code> or a <code>hana::nothing</code> will be returned from a function has to be known at compile-time for the return type of that function to be computable by the compiler. This makes <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> well suited for static metaprogramming tasks, but very poor for anything dynamic.</p>
  143. <dl class="section note"><dt>Note</dt><dd>When you use a container, remember not to make assumptions about its representation, unless the documentation gives you those guarantees. More details <a class="el" href="index.html#tutorial-containers-types">in the tutorial</a>.</dd></dl>
  144. <h2>Interoperation with <code>type</code>s </h2>
  145. <p>When a <code>just</code> contains an object of type <code>T</code> which is a <code>type</code>, it has a nested <code>::type</code> alias equivalent to <code>T::type</code>. <code>nothing</code>, however, never has a nested <code>::type</code> alias. If <code>t</code> is a <code>type</code>, this allows <code>decltype(just(t))</code> to be seen as a nullary metafunction equivalent to <code>decltype(t)</code>. Along with the <code>sfinae</code> function, this allows <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> to interact seamlessly with SFINAE-friendly metafunctions. Example: </p><div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="traits_8hpp.html">boost/hana/traits.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;utility&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt;</div><div class="line"><span class="keyword">using</span> void_t = void;</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> = <span class="keywordtype">void</span>&gt;</div><div class="line"><span class="keyword">struct </span>has_type : std::false_type { };</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><span class="keyword">struct </span>has_type&lt;T, void_t&lt;typename T::type&gt;&gt;</div><div class="line"> : std::true_type</div><div class="line">{ };</div><div class="line"></div><div class="line"><span class="keyword">auto</span> common_type_impl = hana::sfinae([](<span class="keyword">auto</span> t, <span class="keyword">auto</span> u) -&gt; hana::type&lt;</div><div class="line"> decltype(<span class="keyword">true</span> ? hana::traits::declval(t) : hana::traits::declval(u))</div><div class="line">&gt; { <span class="keywordflow">return</span> {}; });</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;</div><div class="line"><span class="keyword">using</span> common_type = decltype(common_type_impl(hana::type_c&lt;T&gt;, hana::type_c&lt;U&gt;));</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div><div class="line"> common_type_impl(hana::type_c&lt;int&gt;, hana::type_c&lt;float&gt;)</div><div class="line"> ==</div><div class="line"> hana::just(hana::type_c&lt;float&gt;)</div><div class="line">);</div><div class="line"></div><div class="line">static_assert(!has_type&lt;common_type&lt;int, int*&gt;&gt;{}, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(std::is_same&lt;common_type&lt;int, float&gt;::type, <span class="keywordtype">float</span>&gt;{}, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --><h2>Modeled concepts </h2>
  146. <ol type="1">
  147. <li><code>Comparable</code><br />
  148. Two <code>optional</code>s are equal if and only if they are both empty or they both contain a value and those values are equal. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::nothing == hana::nothing);</div><div class="line">static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>) != hana::just(<span class="charliteral">&#39;y&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::just(<span class="charliteral">&#39;x&#39;</span>) != hana::nothing);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
  149. <li><code>Orderable</code><br />
  150. Optional values can be ordered by considering the value they are holding, if any. To handle the case of an empty optional value, we arbitrarily set <code>nothing</code> as being less than any other <code>just</code>. Hence, <div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x) &lt; <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(y) <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> x &lt; y</div><div class="line"><a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a> &lt; <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(anything)</div></div><!-- fragment --> Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="greater_8hpp.html">boost/hana/greater.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="less_8hpp.html">boost/hana/less.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::nothing &lt; hana::just(3));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::just(0) &gt; hana::nothing);</div><div class="line">static_assert(hana::just(1) &lt; hana::just(3), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::just(3) &gt; hana::just(2), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
  151. <li><code>Functor</code><br />
  152. An optional value can be seen as a list containing either one element (<code>just(x)</code>) or no elements at all (<code>nothing</code>). As such, mapping a function over an optional value is equivalent to applying it to its value if there is one, and to <code>nothing</code> otherwise: <div class="fragment"><div class="line"><a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(<a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x), f) == <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f(x))</div><div class="line"><a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(<a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>, f) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div></div><!-- fragment --> Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="placeholder_8hpp.html">boost/hana/functional/placeholder.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="transform_8hpp.html">boost/hana/transform.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">hana::transform</a>(hana::nothing, <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1) == hana::nothing);</div><div class="line">static_assert(<a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">hana::transform</a>(hana::just(1), <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1) == hana::just(2), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
  153. <li><code>Applicative</code><br />
  154. First, a value can be made optional with <code>lift&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;</code>, which is equivalent to <code>just</code>. Second, one can feed an optional value to an optional function with <code>ap</code>, which will return <code>just(f(x))</code> if there is both a function <em>and</em> a value, and <code>nothing</code> otherwise: <div class="fragment"><div class="line"><a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">ap</a>(<a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f), <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x)) == <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f(x))</div><div class="line"><a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">ap</a>(<a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>, <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x)) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div><div class="line"><a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">ap</a>(<a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f), <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div><div class="line"><a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">ap</a>(<a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>, <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div></div><!-- fragment --> A simple example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ap_8hpp.html">boost/hana/ap.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">constexpr <span class="keywordtype">char</span> next(<span class="keywordtype">char</span> c) { <span class="keywordflow">return</span> c + 1; }</div><div class="line"></div><div class="line">static_assert(<a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">hana::ap</a>(hana::just(next), hana::just(<span class="charliteral">&#39;x&#39;</span>)) == hana::just(<span class="charliteral">&#39;y&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">hana::ap</a>(hana::nothing, hana::just(<span class="charliteral">&#39;x&#39;</span>)) == hana::nothing);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">hana::ap</a>(hana::just(next), hana::nothing) == hana::nothing);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">hana::ap</a>(hana::nothing, hana::nothing) == hana::nothing);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --> A more complex example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ap_8hpp.html">boost/hana/ap.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="bool_8hpp.html">boost/hana/bool.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="if_8hpp.html">boost/hana/if.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="lift_8hpp.html">boost/hana/lift.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keywordtype">char</span> op&gt;</div><div class="line">constexpr <span class="keyword">auto</span> <span class="keyword">function</span> = hana::nothing;</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;&gt;</div><div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> function&lt;&#39;+&#39;&gt; = hana::just([](<span class="keyword">auto</span> x, <span class="keyword">auto</span> y) {</div><div class="line"> <span class="keywordflow">return</span> x + y;</div><div class="line">});</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;&gt;</div><div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <span class="keyword">function</span>&lt;<span class="charliteral">&#39;-&#39;</span>&gt; = hana::just([](<span class="keyword">auto</span> x, <span class="keyword">auto</span> y) {</div><div class="line"> <span class="keywordflow">return</span> x - y;</div><div class="line">});</div><div class="line"></div><div class="line"><span class="comment">// and so on...</span></div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keywordtype">char</span> n&gt;</div><div class="line">constexpr <span class="keyword">auto</span> digit = <a class="code" href="group__group-Logical.html#gafd655d2222367131e7a63616e93dd080">hana::if_</a>(hana::bool_c&lt;(n &gt;= <span class="charliteral">&#39;0&#39;</span> &amp;&amp; n &lt;= <span class="charliteral">&#39;9&#39;</span>)&gt;,</div><div class="line"> hana::just(static_cast&lt;int&gt;(n - 48)),</div><div class="line"> hana::nothing</div><div class="line">);</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keywordtype">char</span> x, <span class="keywordtype">char</span> op, <span class="keywordtype">char</span> y&gt;</div><div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> evaluate = <a class="code" href="group__group-Applicative.html#ga6176a32953dbbdee96e3ab3c73e4c890">hana::ap</a>(function&lt;op&gt;, digit&lt;x&gt;, digit&lt;y&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(evaluate&lt;&#39;1&#39;, &#39;+&#39;, &#39;2&#39;&gt; == hana::just(1 + 2));</div><div class="line"> <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(evaluate&lt;&#39;4&#39;, &#39;-&#39;, &#39;2&#39;&gt; == hana::just(4 - 2));</div><div class="line"></div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;?&#39;, &#39;+&#39;, &#39;2&#39;&gt; == hana::nothing);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;1&#39;, &#39;?&#39;, &#39;2&#39;&gt; == hana::nothing);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;1&#39;, &#39;+&#39;, &#39;?&#39;&gt; == hana::nothing);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;?&#39;, &#39;?&#39;, &#39;?&#39;&gt; == hana::nothing);</div><div class="line"></div><div class="line"> static_assert(hana::lift&lt;hana::optional_tag&gt;(123) == hana::just(123), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">}</div></div><!-- fragment --></li>
  155. <li><code>Monad</code><br />
  156. The <code>Monad</code> model makes it easy to compose actions that might fail. One can feed an optional value if there is one into a function with <code>chain</code>, which will return <code>nothing</code> if there is no value. Finally, optional-optional values can have their redundant level of optionality removed with <code>flatten</code>. Also note that the <code>|</code> operator can be used in place of the <code>chain</code> function. Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="chain_8hpp.html">boost/hana/chain.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="flatten_8hpp.html">boost/hana/flatten.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> inc = [](<span class="keyword">auto</span> x) {</div><div class="line"> <span class="keywordflow">return</span> hana::just(x + 1);</div><div class="line"> };</div><div class="line"></div><div class="line"> <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(<a class="code" href="group__group-Monad.html#ga05fdc2f887cb9967357487a432ace98b">hana::chain</a>(hana::just(1), inc) == hana::just(2));</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Monad.html#ga05fdc2f887cb9967357487a432ace98b">hana::chain</a>(hana::nothing, inc) == hana::nothing);</div><div class="line"></div><div class="line"> <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(<a class="code" href="group__group-Monad.html#gaa5fec6fb418de5da3ecb500fd6cc54dd">hana::flatten</a>(hana::just(hana::just(2))) == hana::just(2));</div><div class="line">}</div></div><!-- fragment --></li>
  157. <li><code>MonadPlus</code><br />
  158. The <code>MonadPlus</code> model allows choosing the first valid value out of two optional values with <code>concat</code>. If both optional values are <code>nothing</code>s, <code>concat</code> will return <code>nothing</code>. Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="concat_8hpp.html">boost/hana/concat.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="empty_8hpp.html">boost/hana/empty.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">static_assert(<a class="code" href="group__group-MonadPlus.html#ga1946e96c3b4c178c7ae8703724c29c37">hana::concat</a>(hana::nothing, hana::just(<span class="charliteral">&#39;x&#39;</span>)) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-MonadPlus.html#ga1946e96c3b4c178c7ae8703724c29c37">hana::concat</a>(hana::nothing, hana::nothing) == hana::nothing);</div><div class="line">static_assert(<a class="code" href="group__group-MonadPlus.html#ga1946e96c3b4c178c7ae8703724c29c37">hana::concat</a>(hana::just(<span class="charliteral">&#39;x&#39;</span>), hana::just(<span class="charliteral">&#39;y&#39;</span>)) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::empty&lt;hana::optional_tag&gt;() == hana::nothing);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
  159. <li><code>Foldable</code><br />
  160. Folding an optional value is equivalent to folding a list containing either no elements (for <code>nothing</code>) or <code>x</code> (for <code>just(x)</code>). Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="fold__right_8hpp.html">boost/hana/fold_right.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="plus_8hpp.html">boost/hana/plus.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">static_assert(<a class="code" href="group__group-Foldable.html#ga77d43badebd59b046cf93598733649b4">hana::fold_right</a>(hana::nothing, 1, <a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">hana::plus</a>) == 1, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(<a class="code" href="group__group-Foldable.html#ga77d43badebd59b046cf93598733649b4">hana::fold_right</a>(hana::just(4), 1, <a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">hana::plus</a>) == 5, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
  161. <li><code>Searchable</code><br />
  162. Searching an optional value is equivalent to searching a list containing <code>x</code> for <code>just(x)</code> and an empty list for <code>nothing</code>. Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="all__of_8hpp.html">boost/hana/all_of.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="find__if_8hpp.html">boost/hana/find_if.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="mod_8hpp.html">boost/hana/mod.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">auto</span> odd = [](<span class="keyword">auto</span> x) {</div><div class="line"> <span class="keywordflow">return</span> x % hana::int_c&lt;2&gt; != hana::int_c&lt;0&gt;;</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(hana::just(hana::int_c&lt;3&gt;), odd) == hana::just(hana::int_c&lt;3&gt;));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(hana::just(hana::int_c&lt;2&gt;), odd) == hana::nothing);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(hana::nothing, odd) == hana::nothing);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::just(hana::int_c&lt;3&gt;), odd));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::nothing, odd));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --> </li>
  163. </ol>
  164. </div><table class="memberdecls">
  165. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="related"></a>
  166. Synopsis of associated functions</h2></td></tr>
  167. <tr class="memitem:a76a84854b3051af000e698157d63a6a8"><td class="memTemplParams" colspan="2">template&lt;&gt; </td></tr>
  168. <tr class="memitem:a76a84854b3051af000e698157d63a6a8"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a76a84854b3051af000e698157d63a6a8">make&lt; optional_tag &gt;</a></td></tr>
  169. <tr class="memdesc:a76a84854b3051af000e698157d63a6a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create an optional value. <a href="#a76a84854b3051af000e698157d63a6a8">More...</a><br /></td></tr>
  170. <tr class="separator:a76a84854b3051af000e698157d63a6a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
  171. <tr class="memitem:af1105a435d6435a2437cb5dc162ba463"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#af1105a435d6435a2437cb5dc162ba463">make_optional</a> = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html">optional_tag</a>&gt;</td></tr>
  172. <tr class="memdesc:af1105a435d6435a2437cb5dc162ba463"><td class="mdescLeft">&#160;</td><td class="mdescRight">Alias to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;</code>; provided for convenience. <a href="#af1105a435d6435a2437cb5dc162ba463">More...</a><br /></td></tr>
  173. <tr class="separator:af1105a435d6435a2437cb5dc162ba463"><td class="memSeparator" colspan="2">&#160;</td></tr>
  174. <tr class="memitem:a8ad818d6df7379b0adefa45d2ac844d0"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a></td></tr>
  175. <tr class="memdesc:a8ad818d6df7379b0adefa45d2ac844d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create an optional value containing <code>x</code>. <a href="#a8ad818d6df7379b0adefa45d2ac844d0">More...</a><br /></td></tr>
  176. <tr class="separator:a8ad818d6df7379b0adefa45d2ac844d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
  177. <tr class="memitem:a0c315287473aa87fe5ccd9d8a1c10186"><td class="memItemLeft" align="right" valign="top">constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a> {}</td></tr>
  178. <tr class="memdesc:a0c315287473aa87fe5ccd9d8a1c10186"><td class="mdescLeft">&#160;</td><td class="mdescRight">An empty optional value. <a href="#a0c315287473aa87fe5ccd9d8a1c10186">More...</a><br /></td></tr>
  179. <tr class="separator:a0c315287473aa87fe5ccd9d8a1c10186"><td class="memSeparator" colspan="2">&#160;</td></tr>
  180. <tr class="memitem:a6529e11cb228e99a05e81071752807d5"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a6529e11cb228e99a05e81071752807d5">maybe</a></td></tr>
  181. <tr class="memdesc:a6529e11cb228e99a05e81071752807d5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a function to the contents of an optional, with a fallback result. <a href="#a6529e11cb228e99a05e81071752807d5">More...</a><br /></td></tr>
  182. <tr class="separator:a6529e11cb228e99a05e81071752807d5"><td class="memSeparator" colspan="2">&#160;</td></tr>
  183. <tr class="memitem:aa4c8c0b1ef3d8206974734b93646c9fd"><td class="memItemLeft" align="right" valign="top">auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aa4c8c0b1ef3d8206974734b93646c9fd">sfinae</a></td></tr>
  184. <tr class="memdesc:aa4c8c0b1ef3d8206974734b93646c9fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calls a function if the call expression is well-formed. <a href="#aa4c8c0b1ef3d8206974734b93646c9fd">More...</a><br /></td></tr>
  185. <tr class="separator:aa4c8c0b1ef3d8206974734b93646c9fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
  186. <tr class="memitem:a1047a69893a62cd36eb0d2934f85e0e7"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a1047a69893a62cd36eb0d2934f85e0e7">is_just</a></td></tr>
  187. <tr class="memdesc:a1047a69893a62cd36eb0d2934f85e0e7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return whether an <code>optional</code> contains a value. <a href="#a1047a69893a62cd36eb0d2934f85e0e7">More...</a><br /></td></tr>
  188. <tr class="separator:a1047a69893a62cd36eb0d2934f85e0e7"><td class="memSeparator" colspan="2">&#160;</td></tr>
  189. <tr class="memitem:a4eb266d123883c23853f7731a6c5953f"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a4eb266d123883c23853f7731a6c5953f">is_nothing</a></td></tr>
  190. <tr class="memdesc:a4eb266d123883c23853f7731a6c5953f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return whether an <code>optional</code> is empty. <a href="#a4eb266d123883c23853f7731a6c5953f">More...</a><br /></td></tr>
  191. <tr class="separator:a4eb266d123883c23853f7731a6c5953f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  192. </table><table class="memberdecls">
  193. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
  194. Friends</h2></td></tr>
  195. <tr class="memitem:a833b9d5d44bb431621af9129994b9bbc"><td class="memTemplParams" colspan="2"><a id="a833b9d5d44bb431621af9129994b9bbc"></a>
  196. template&lt;typename ... T, typename F &gt; </td></tr>
  197. <tr class="memitem:a833b9d5d44bb431621af9129994b9bbc"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a833b9d5d44bb431621af9129994b9bbc">operator|</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a>&lt; T... &gt;, F)</td></tr>
  198. <tr class="memdesc:a833b9d5d44bb431621af9129994b9bbc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Monad.html#ga05fdc2f887cb9967357487a432ace98b" title="Feed a monadic value into a monadic computation.Given a monadic value and a monadic function,...">hana::chain</a></code>. <br /></td></tr>
  199. <tr class="separator:a833b9d5d44bb431621af9129994b9bbc"><td class="memSeparator" colspan="2">&#160;</td></tr>
  200. <tr class="memitem:a27607958295e6da8a0ba602a2db468f1"><td class="memTemplParams" colspan="2"><a id="a27607958295e6da8a0ba602a2db468f1"></a>
  201. template&lt;typename X , typename Y &gt; </td></tr>
  202. <tr class="memitem:a27607958295e6da8a0ba602a2db468f1"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a27607958295e6da8a0ba602a2db468f1">operator==</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  203. <tr class="memdesc:a27607958295e6da8a0ba602a2db468f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547" title="Returns a Logical representing whether x is equal to y.The equal function can be called in two differ...">hana::equal</a></code> <br /></td></tr>
  204. <tr class="separator:a27607958295e6da8a0ba602a2db468f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
  205. <tr class="memitem:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memTemplParams" colspan="2"><a id="a0cae3af55edb3eb05bfa184bda633f7d"></a>
  206. template&lt;typename X , typename Y &gt; </td></tr>
  207. <tr class="memitem:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  208. <tr class="memdesc:a0cae3af55edb3eb05bfa184bda633f7d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd" title="Returns a Logical representing whether x is not equal to y.The not_equal function can be called in tw...">hana::not_equal</a></code> <br /></td></tr>
  209. <tr class="separator:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  210. <tr class="memitem:ada078dcf9e68b8e9a82b33c75dde8457"><td class="memTemplParams" colspan="2"><a id="ada078dcf9e68b8e9a82b33c75dde8457"></a>
  211. template&lt;typename X , typename Y &gt; </td></tr>
  212. <tr class="memitem:ada078dcf9e68b8e9a82b33c75dde8457"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#ada078dcf9e68b8e9a82b33c75dde8457">operator&lt;</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  213. <tr class="memdesc:ada078dcf9e68b8e9a82b33c75dde8457"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9" title="Returns a Logical representing whether x is less than y.">hana::less</a></code> <br /></td></tr>
  214. <tr class="separator:ada078dcf9e68b8e9a82b33c75dde8457"><td class="memSeparator" colspan="2">&#160;</td></tr>
  215. <tr class="memitem:aedd11fddefddbbbb87d3b24c7117528f"><td class="memTemplParams" colspan="2"><a id="aedd11fddefddbbbb87d3b24c7117528f"></a>
  216. template&lt;typename X , typename Y &gt; </td></tr>
  217. <tr class="memitem:aedd11fddefddbbbb87d3b24c7117528f"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aedd11fddefddbbbb87d3b24c7117528f">operator&gt;</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  218. <tr class="memdesc:aedd11fddefddbbbb87d3b24c7117528f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198" title="Returns a Logical representing whether x is greater than y.">hana::greater</a></code> <br /></td></tr>
  219. <tr class="separator:aedd11fddefddbbbb87d3b24c7117528f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  220. <tr class="memitem:a53817979990da799e659b2576799a79a"><td class="memTemplParams" colspan="2"><a id="a53817979990da799e659b2576799a79a"></a>
  221. template&lt;typename X , typename Y &gt; </td></tr>
  222. <tr class="memitem:a53817979990da799e659b2576799a79a"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a53817979990da799e659b2576799a79a">operator&lt;=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  223. <tr class="memdesc:a53817979990da799e659b2576799a79a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851" title="Returns a Logical representing whether x is less than or equal to y.">hana::less_equal</a></code> <br /></td></tr>
  224. <tr class="separator:a53817979990da799e659b2576799a79a"><td class="memSeparator" colspan="2">&#160;</td></tr>
  225. <tr class="memitem:aa3f0436b623de5208767751e1e9f7e59"><td class="memTemplParams" colspan="2"><a id="aa3f0436b623de5208767751e1e9f7e59"></a>
  226. template&lt;typename X , typename Y &gt; </td></tr>
  227. <tr class="memitem:aa3f0436b623de5208767751e1e9f7e59"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aa3f0436b623de5208767751e1e9f7e59">operator&gt;=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  228. <tr class="memdesc:aa3f0436b623de5208767751e1e9f7e59"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703" title="Returns a Logical representing whether x is greater than or equal to y.">hana::greater_equal</a></code> <br /></td></tr>
  229. <tr class="separator:aa3f0436b623de5208767751e1e9f7e59"><td class="memSeparator" colspan="2">&#160;</td></tr>
  230. </table><table class="memberdecls">
  231. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
  232. Public Member Functions</h2></td></tr>
  233. <tr class="memitem:aefbd278cf7bb9e921707d6d827014bcb"><td class="memItemLeft" align="right" valign="top"><a id="aefbd278cf7bb9e921707d6d827014bcb"></a>
  234. constexpr&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">optional</a> ()=default</td></tr>
  235. <tr class="memdesc:aefbd278cf7bb9e921707d6d827014bcb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default-construct an <code>optional</code>. Only exists if the optional contains a value, and if that value is DefaultConstructible. <br /></td></tr>
  236. <tr class="separator:aefbd278cf7bb9e921707d6d827014bcb"><td class="memSeparator" colspan="2">&#160;</td></tr>
  237. <tr class="memitem:a9074406adb54a6a848ba482895c51d1f"><td class="memItemLeft" align="right" valign="top"><a id="a9074406adb54a6a848ba482895c51d1f"></a>
  238. &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a9074406adb54a6a848ba482895c51d1f">optional</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> const &amp;)=default</td></tr>
  239. <tr class="memdesc:a9074406adb54a6a848ba482895c51d1f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy-construct an <code>optional</code>. An empty optional may only be copy-constructed from another empty <code>optional</code>, and an <code>optional</code> with a value may only be copy-constructed from another <code>optional</code> with a value. Furthermore, this constructor only exists if the value held in the <code>optional</code> is CopyConstructible. <br /></td></tr>
  240. <tr class="separator:a9074406adb54a6a848ba482895c51d1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  241. <tr class="memitem:ac46a23f0ada20175c4c9a58af3d15753"><td class="memItemLeft" align="right" valign="top"><a id="ac46a23f0ada20175c4c9a58af3d15753"></a>
  242. &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#ac46a23f0ada20175c4c9a58af3d15753">optional</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&amp;)=default</td></tr>
  243. <tr class="memdesc:ac46a23f0ada20175c4c9a58af3d15753"><td class="mdescLeft">&#160;</td><td class="mdescRight">Move-construct an <code>optional</code>. An empty optional may only be move-constructed from another empty <code>optional</code>, and an <code>optional</code> with a value may only be move-constructed from another <code>optional</code> with a value. Furthermore, this constructor only exists if the value held in the <code>optional</code> is MoveConstructible. <br /></td></tr>
  244. <tr class="separator:ac46a23f0ada20175c4c9a58af3d15753"><td class="memSeparator" colspan="2">&#160;</td></tr>
  245. <tr class="memitem:a2b04ee87c0ac58621edf3ad5476a2949"><td class="memItemLeft" align="right" valign="top"><a id="a2b04ee87c0ac58621edf3ad5476a2949"></a>
  246. constexpr&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a2b04ee87c0ac58621edf3ad5476a2949">optional</a> (T const &amp;t)</td></tr>
  247. <tr class="memdesc:a2b04ee87c0ac58621edf3ad5476a2949"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct an <code>optional</code> holding a value of type <code>T</code> from another object of type <code>T</code>. The value is copy-constructed. <br /></td></tr>
  248. <tr class="separator:a2b04ee87c0ac58621edf3ad5476a2949"><td class="memSeparator" colspan="2">&#160;</td></tr>
  249. <tr class="memitem:adf824827b5d6f8c87d23b9526b9f35d2"><td class="memItemLeft" align="right" valign="top"><a id="adf824827b5d6f8c87d23b9526b9f35d2"></a>
  250. constexpr&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#adf824827b5d6f8c87d23b9526b9f35d2">optional</a> (T &amp;&amp;t)</td></tr>
  251. <tr class="memdesc:adf824827b5d6f8c87d23b9526b9f35d2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct an <code>optional</code> holding a value of type <code>T</code> from another object of type <code>T</code>. The value is move-constructed. <br /></td></tr>
  252. <tr class="separator:adf824827b5d6f8c87d23b9526b9f35d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
  253. <tr class="memitem:abefc885243f38c66c52fdada3588f951"><td class="memItemLeft" align="right" valign="top"><a id="abefc885243f38c66c52fdada3588f951"></a>
  254. constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#abefc885243f38c66c52fdada3588f951">operator=</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> const &amp;)=default</td></tr>
  255. <tr class="memdesc:abefc885243f38c66c52fdada3588f951"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy-assign an <code>optional</code>. An empty optional may only be copy-assigned from another empty <code>optional</code>, and an <code>optional</code> with a value may only be copy-assigned from another <code>optional</code> with a value. Furthermore, this assignment operator only exists if the value held in the <code>optional</code> is CopyAssignable. <br /></td></tr>
  256. <tr class="separator:abefc885243f38c66c52fdada3588f951"><td class="memSeparator" colspan="2">&#160;</td></tr>
  257. <tr class="memitem:a52057c5da4b9aee49ee15a167459fc9a"><td class="memItemLeft" align="right" valign="top"><a id="a52057c5da4b9aee49ee15a167459fc9a"></a>
  258. constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a52057c5da4b9aee49ee15a167459fc9a">operator=</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&amp;)=default</td></tr>
  259. <tr class="memdesc:a52057c5da4b9aee49ee15a167459fc9a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Move-assign an <code>optional</code>. An empty optional may only be move-assigned from another empty <code>optional</code>, and an <code>optional</code> with a value may only be move-assigned from another <code>optional</code> with a value. Furthermore, this assignment operator only exists if the value held in the <code>optional</code> is MoveAssignable. <br /></td></tr>
  260. <tr class="separator:a52057c5da4b9aee49ee15a167459fc9a"><td class="memSeparator" colspan="2">&#160;</td></tr>
  261. <tr class="memitem:a6eeef1512294d408857805eb3a790230"><td class="memItemLeft" align="right" valign="top">constexpr T *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a6eeef1512294d408857805eb3a790230">operator-&gt;</a> ()</td></tr>
  262. <tr class="memdesc:a6eeef1512294d408857805eb3a790230"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a pointer to the contained value, or a <code>nullptr</code> if the <code>optional</code> is empty. <a href="#a6eeef1512294d408857805eb3a790230">More...</a><br /></td></tr>
  263. <tr class="separator:a6eeef1512294d408857805eb3a790230"><td class="memSeparator" colspan="2">&#160;</td></tr>
  264. <tr class="memitem:acdcf71b43d4e27d5efbf0ad875d0be58"><td class="memItemLeft" align="right" valign="top">constexpr T &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a> ()</td></tr>
  265. <tr class="memdesc:acdcf71b43d4e27d5efbf0ad875d0be58"><td class="mdescLeft">&#160;</td><td class="mdescRight">Extract the content of an <code>optional</code>, or fail at compile-time. <a href="#acdcf71b43d4e27d5efbf0ad875d0be58">More...</a><br /></td></tr>
  266. <tr class="separator:acdcf71b43d4e27d5efbf0ad875d0be58"><td class="memSeparator" colspan="2">&#160;</td></tr>
  267. <tr class="memitem:a237b2147dd9b72bb2dfa4a268056e4c2"><td class="memItemLeft" align="right" valign="top">constexpr T &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a237b2147dd9b72bb2dfa4a268056e4c2">operator *</a> ()</td></tr>
  268. <tr class="memdesc:a237b2147dd9b72bb2dfa4a268056e4c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58" title="Extract the content of an optional, or fail at compile-time.">value()</a></code>, provided for convenience. <a href="#a237b2147dd9b72bb2dfa4a268056e4c2">More...</a><br /></td></tr>
  269. <tr class="separator:a237b2147dd9b72bb2dfa4a268056e4c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
  270. <tr class="memitem:a1f511267d94c178e4ef955da60f0888d"><td class="memTemplParams" colspan="2">template&lt;typename U &gt; </td></tr>
  271. <tr class="memitem:a1f511267d94c178e4ef955da60f0888d"><td class="memTemplItemLeft" align="right" valign="top">decltype(auto) constexpr&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a1f511267d94c178e4ef955da60f0888d">value_or</a> (U &amp;&amp;<a class="el" href="structboost_1_1hana_1_1default__.html">default_</a>)</td></tr>
  272. <tr class="memdesc:a1f511267d94c178e4ef955da60f0888d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the contents of an <code>optional</code>, with a fallback result. <a href="#a1f511267d94c178e4ef955da60f0888d">More...</a><br /></td></tr>
  273. <tr class="separator:a1f511267d94c178e4ef955da60f0888d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  274. </table>
  275. <h2 class="groupheader">Associated functions</h2>
  276. <a id="a76a84854b3051af000e698157d63a6a8"></a>
  277. <h2 class="memtitle"><span class="permalink"><a href="#a76a84854b3051af000e698157d63a6a8">&#9670;&nbsp;</a></span>make&lt; optional_tag &gt;</h2>
  278. <div class="memitem">
  279. <div class="memproto">
  280. <div class="memtemplate">
  281. template&lt;typename ... T&gt; </div>
  282. <div class="memtemplate">
  283. template&lt;&gt; </div>
  284. <table class="mlabels">
  285. <tr>
  286. <td class="mlabels-left">
  287. <table class="memname">
  288. <tr>
  289. <td class="memname">constexpr auto <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt; <a class="el" href="structboost_1_1hana_1_1optional__tag.html">optional_tag</a> &gt;</td>
  290. </tr>
  291. </table>
  292. </td>
  293. <td class="mlabels-right">
  294. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  295. </tr>
  296. </table>
  297. </div><div class="memdoc">
  298. <b>Initial value:</b><div class="fragment"><div class="line">= []([<span class="keyword">auto</span>&amp;&amp; x]) {</div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">optional</a>&lt;std::decay&lt;decltype(x)&gt;::type&gt;{forwarded(x)};</div><div class="line"> }</div></div><!-- fragment -->
  299. <p>Create an optional value. </p>
  300. <p>Specifically, <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;()</code> is equivalent to <code>nothing</code>, and <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;(x)</code> is equivalent to <code>just(x)</code>. This is provided for consistency with the other <code>make&lt;...&gt;</code> functions.</p>
  301. <h2>Example </h2>
  302. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2make_8hpp.html">boost/hana/core/make.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> constexpr <span class="keyword">auto</span> x = hana::make&lt;hana::optional_tag&gt;();</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(x == hana::make_optional());</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_nothing(x));</div><div class="line"></div><div class="line"> constexpr <span class="keyword">auto</span> just_x = hana::make&lt;hana::optional_tag&gt;(<span class="charliteral">&#39;x&#39;</span>);</div><div class="line"> static_assert(just_x == hana::make_optional(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_just(just_x));</div><div class="line">}</div></div><!-- fragment -->
  303. </div>
  304. </div>
  305. <a id="af1105a435d6435a2437cb5dc162ba463"></a>
  306. <h2 class="memtitle"><span class="permalink"><a href="#af1105a435d6435a2437cb5dc162ba463">&#9670;&nbsp;</a></span>make_optional</h2>
  307. <div class="memitem">
  308. <div class="memproto">
  309. <div class="memtemplate">
  310. template&lt;typename ... T&gt; </div>
  311. <table class="mlabels">
  312. <tr>
  313. <td class="mlabels-left">
  314. <table class="memname">
  315. <tr>
  316. <td class="memname">constexpr auto make_optional = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html">optional_tag</a>&gt;</td>
  317. </tr>
  318. </table>
  319. </td>
  320. <td class="mlabels-right">
  321. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  322. </tr>
  323. </table>
  324. </div><div class="memdoc">
  325. <p>Alias to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;</code>; provided for convenience. </p>
  326. <h2>Example </h2>
  327. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2make_8hpp.html">boost/hana/core/make.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> constexpr <span class="keyword">auto</span> x = hana::make&lt;hana::optional_tag&gt;();</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(x == hana::make_optional());</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_nothing(x));</div><div class="line"></div><div class="line"> constexpr <span class="keyword">auto</span> just_x = hana::make&lt;hana::optional_tag&gt;(<span class="charliteral">&#39;x&#39;</span>);</div><div class="line"> static_assert(just_x == hana::make_optional(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_just(just_x));</div><div class="line">}</div></div><!-- fragment -->
  328. </div>
  329. </div>
  330. <a id="a8ad818d6df7379b0adefa45d2ac844d0"></a>
  331. <h2 class="memtitle"><span class="permalink"><a href="#a8ad818d6df7379b0adefa45d2ac844d0">&#9670;&nbsp;</a></span>just</h2>
  332. <div class="memitem">
  333. <div class="memproto">
  334. <div class="memtemplate">
  335. template&lt;typename ... T&gt; </div>
  336. <table class="mlabels">
  337. <tr>
  338. <td class="mlabels-left">
  339. <table class="memname">
  340. <tr>
  341. <td class="memname">constexpr auto just</td>
  342. </tr>
  343. </table>
  344. </td>
  345. <td class="mlabels-right">
  346. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  347. </tr>
  348. </table>
  349. </div><div class="memdoc">
  350. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">optional</a>&lt;std::decay&lt;decltype(x)&gt;::type&gt;{forwarded(x)};</div><div class="line"> }</div></div><!-- fragment -->
  351. <p>Create an optional value containing <code>x</code>. </p>
  352. <h2>Example </h2>
  353. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">constexpr <span class="keyword">auto</span> just_x = hana::just(<span class="charliteral">&#39;x&#39;</span>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_just(just_x));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  354. </div>
  355. </div>
  356. <a id="a0c315287473aa87fe5ccd9d8a1c10186"></a>
  357. <h2 class="memtitle"><span class="permalink"><a href="#a0c315287473aa87fe5ccd9d8a1c10186">&#9670;&nbsp;</a></span>nothing</h2>
  358. <div class="memitem">
  359. <div class="memproto">
  360. <div class="memtemplate">
  361. template&lt;typename ... T&gt; </div>
  362. <table class="mlabels">
  363. <tr>
  364. <td class="mlabels-left">
  365. <table class="memname">
  366. <tr>
  367. <td class="memname">constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> nothing {}</td>
  368. </tr>
  369. </table>
  370. </td>
  371. <td class="mlabels-right">
  372. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  373. </tr>
  374. </table>
  375. </div><div class="memdoc">
  376. <p>An empty optional value. </p>
  377. <h2>Example </h2>
  378. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">constexpr <span class="keyword">auto</span> x = hana::nothing;</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_nothing(x));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  379. </div>
  380. </div>
  381. <a id="a6529e11cb228e99a05e81071752807d5"></a>
  382. <h2 class="memtitle"><span class="permalink"><a href="#a6529e11cb228e99a05e81071752807d5">&#9670;&nbsp;</a></span>maybe</h2>
  383. <div class="memitem">
  384. <div class="memproto">
  385. <div class="memtemplate">
  386. template&lt;typename ... T&gt; </div>
  387. <table class="mlabels">
  388. <tr>
  389. <td class="mlabels-left">
  390. <table class="memname">
  391. <tr>
  392. <td class="memname">constexpr auto maybe</td>
  393. </tr>
  394. </table>
  395. </td>
  396. <td class="mlabels-right">
  397. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  398. </tr>
  399. </table>
  400. </div><div class="memdoc">
  401. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; default_, <span class="keyword">auto</span>&amp;&amp; f, <span class="keyword">auto</span>&amp;&amp; m) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line"> <span class="keywordflow">if</span> (m is a <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x)) {</div><div class="line"> <span class="keywordflow">return</span> forwarded(f)(forwarded(x));</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">return</span> forwarded(default_);</div><div class="line"> }</div><div class="line"> }</div></div><!-- fragment -->
  402. <p>Apply a function to the contents of an optional, with a fallback result. </p>
  403. <p>Specifically, <code>maybe</code> takes a default value, a function and an optional value. If the optional value is <code>nothing</code>, the default value is returned. Otherwise, the function is applied to the content of the <code>just</code>.</p>
  404. <dl class="params"><dt>Parameters</dt><dd>
  405. <table class="params">
  406. <tr><td class="paramname"><a class="el" href="structboost_1_1hana_1_1default__.html" title="Mark a tag-dispatched method implementation as a default implementation.">default_</a></td><td>A default value returned if <code>m</code> is <code>nothing</code>.</td></tr>
  407. <tr><td class="paramname">f</td><td>A function called as <code>f(x)</code> if and only if <code>m</code> is an optional value of the form <code>just(x)</code>. In that case, the result returend by <code>maybe</code> is the result of <code>f</code>.</td></tr>
  408. <tr><td class="paramname">m</td><td>An optional value.</td></tr>
  409. </table>
  410. </dd>
  411. </dl>
  412. <h2>Example </h2>
  413. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="placeholder_8hpp.html">boost/hana/functional/placeholder.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">static_assert(hana::maybe(<span class="charliteral">&#39;x&#39;</span>, <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1, hana::just(1)) == 2, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::maybe(<span class="charliteral">&#39;x&#39;</span>, <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1, hana::nothing) == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  414. </div>
  415. </div>
  416. <a id="aa4c8c0b1ef3d8206974734b93646c9fd"></a>
  417. <h2 class="memtitle"><span class="permalink"><a href="#aa4c8c0b1ef3d8206974734b93646c9fd">&#9670;&nbsp;</a></span>sfinae</h2>
  418. <div class="memitem">
  419. <div class="memproto">
  420. <div class="memtemplate">
  421. template&lt;typename ... T&gt; </div>
  422. <table class="mlabels">
  423. <tr>
  424. <td class="mlabels-left">
  425. <table class="memname">
  426. <tr>
  427. <td class="memname">auto sfinae</td>
  428. </tr>
  429. </table>
  430. </td>
  431. <td class="mlabels-right">
  432. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  433. </tr>
  434. </table>
  435. </div><div class="memdoc">
  436. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; f) {</div><div class="line"> <span class="keywordflow">return</span> [perfect-<a class="code" href="group__group-functional.html#ga41ada6b336e9d5bcb101ff0c737acbd0">capture</a>](<span class="keyword">auto</span>&amp;&amp; ...x) {</div><div class="line"> <span class="keywordflow">if</span> (decltype(forwarded(f)(forwarded(x)...)) is well-formed)</div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(forwarded(f)(forwarded(x)...));</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>;</div><div class="line"> };</div><div class="line"> }</div></div><!-- fragment -->
  437. <p>Calls a function if the call expression is well-formed. </p>
  438. <p>Given a function <code>f</code>, <code>sfinae</code> returns a new function applying <code>f</code> to its arguments and returning <code>just</code> the result if the call is well-formed, and <code>nothing</code> otherwise. In other words, <code>sfinae(f)(x...)</code> is <code>just(f(x...))</code> if that expression is well-formed, and <code>nothing</code> otherwise. Note, however, that it is possible for an expression <code>f(x...)</code> to be well-formed as far as SFINAE is concerned, but trying to actually compile <code>f(x...)</code> still fails. In this case, <code>sfinae</code> won't be able to detect it and a hard failure is likely to happen.</p>
  439. <dl class="section note"><dt>Note</dt><dd>The function given to <code>sfinae</code> must not return <code>void</code>, since <code>just(void)</code> does not make sense. A compilation error is triggered if the function returns void.</dd></dl>
  440. <h2>Example </h2>
  441. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> incr = [](<span class="keyword">auto</span> x) -&gt; decltype(x + 1) {</div><div class="line"> <span class="keywordflow">return</span> x + 1;</div><div class="line"> };</div><div class="line"></div><div class="line"> <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(hana::sfinae(incr)(1) == hana::just(2));</div><div class="line"></div><div class="line"> <span class="keyword">struct </span>invalid { };</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::sfinae(incr)(invalid{}) == hana::nothing);</div><div class="line">}</div></div><!-- fragment -->
  442. </div>
  443. </div>
  444. <a id="a1047a69893a62cd36eb0d2934f85e0e7"></a>
  445. <h2 class="memtitle"><span class="permalink"><a href="#a1047a69893a62cd36eb0d2934f85e0e7">&#9670;&nbsp;</a></span>is_just</h2>
  446. <div class="memitem">
  447. <div class="memproto">
  448. <div class="memtemplate">
  449. template&lt;typename ... T&gt; </div>
  450. <table class="mlabels">
  451. <tr>
  452. <td class="mlabels-left">
  453. <table class="memname">
  454. <tr>
  455. <td class="memname">constexpr auto is_just</td>
  456. </tr>
  457. </table>
  458. </td>
  459. <td class="mlabels-right">
  460. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  461. </tr>
  462. </table>
  463. </div><div class="memdoc">
  464. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span> <span class="keyword">const</span>&amp; m) {</div><div class="line"> <span class="keywordflow">return</span> m is a <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x);</div><div class="line"> }</div></div><!-- fragment -->
  465. <p>Return whether an <code>optional</code> contains a value. </p>
  466. <p>Specifically, returns a compile-time true-valued <code>Logical</code> if <code>m</code> is of the form <code>just(x)</code> for some <code>x</code>, and a false-valued one otherwise.</p>
  467. <h2>Example </h2>
  468. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>( hana::is_just(hana::just(<span class="charliteral">&#39;x&#39;</span>)));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>( hana::is_just(hana::just(hana::nothing)));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(!hana::is_just(hana::nothing));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  469. </div>
  470. </div>
  471. <a id="a4eb266d123883c23853f7731a6c5953f"></a>
  472. <h2 class="memtitle"><span class="permalink"><a href="#a4eb266d123883c23853f7731a6c5953f">&#9670;&nbsp;</a></span>is_nothing</h2>
  473. <div class="memitem">
  474. <div class="memproto">
  475. <div class="memtemplate">
  476. template&lt;typename ... T&gt; </div>
  477. <table class="mlabels">
  478. <tr>
  479. <td class="mlabels-left">
  480. <table class="memname">
  481. <tr>
  482. <td class="memname">constexpr auto is_nothing</td>
  483. </tr>
  484. </table>
  485. </td>
  486. <td class="mlabels-right">
  487. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  488. </tr>
  489. </table>
  490. </div><div class="memdoc">
  491. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span> <span class="keyword">const</span>&amp; m) {</div><div class="line"> <span class="keywordflow">return</span> m is a <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>;</div><div class="line"> }</div></div><!-- fragment -->
  492. <p>Return whether an <code>optional</code> is empty. </p>
  493. <p>Specifically, returns a compile-time true-valued <code>Logical</code> if <code>m</code> is a <code>nothing</code>, and a false-valued one otherwise.</p>
  494. <h2>Example </h2>
  495. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>( hana::is_nothing(hana::nothing));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(!hana::is_nothing(hana::just(<span class="charliteral">&#39;x&#39;</span>)));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(!hana::is_nothing(hana::just(hana::nothing)));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  496. </div>
  497. </div>
  498. <h2 class="groupheader">Member Function Documentation</h2>
  499. <a id="a6eeef1512294d408857805eb3a790230"></a>
  500. <h2 class="memtitle"><span class="permalink"><a href="#a6eeef1512294d408857805eb3a790230">&#9670;&nbsp;</a></span>operator-&gt;()</h2>
  501. <div class="memitem">
  502. <div class="memproto">
  503. <div class="memtemplate">
  504. template&lt;typename ... T&gt; </div>
  505. <table class="memname">
  506. <tr>
  507. <td class="memname">constexpr T* <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::operator-&gt; </td>
  508. <td>(</td>
  509. <td class="paramname"></td><td>)</td>
  510. <td></td>
  511. </tr>
  512. </table>
  513. </div><div class="memdoc">
  514. <p>Returns a pointer to the contained value, or a <code>nullptr</code> if the <code>optional</code> is empty. </p>
  515. <dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for both the <code>const</code> and the non-<code>const</code> cases.</dd></dl>
  516. <h2>Example </h2>
  517. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>).<a class="code" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a>() == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(*hana::just(hana::type_c&lt;int&gt;) == hana::type_c&lt;int&gt;);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::just(std::string{<span class="stringliteral">&quot;abcd&quot;</span>})-&gt;<a class="code" href="group__group-Foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">size</a>() == 4);</div><div class="line"></div><div class="line"> <span class="comment">// hana::nothing.value(); // compile-time error</span></div><div class="line">}</div></div><!-- fragment -->
  518. </div>
  519. </div>
  520. <a id="acdcf71b43d4e27d5efbf0ad875d0be58"></a>
  521. <h2 class="memtitle"><span class="permalink"><a href="#acdcf71b43d4e27d5efbf0ad875d0be58">&#9670;&nbsp;</a></span>value()</h2>
  522. <div class="memitem">
  523. <div class="memproto">
  524. <div class="memtemplate">
  525. template&lt;typename ... T&gt; </div>
  526. <table class="memname">
  527. <tr>
  528. <td class="memname">constexpr T&amp; <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::value </td>
  529. <td>(</td>
  530. <td class="paramname"></td><td>)</td>
  531. <td></td>
  532. </tr>
  533. </table>
  534. </div><div class="memdoc">
  535. <p>Extract the content of an <code>optional</code>, or fail at compile-time. </p>
  536. <p>If <code>*this</code> contains a value, that value is returned. Otherwise, a static assertion is triggered.</p>
  537. <dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for the cases where <code>*this</code> is a reference, a rvalue-reference and their <code>const</code> counterparts.</dd></dl>
  538. <h2>Example </h2>
  539. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>).<a class="code" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a>() == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(*hana::just(hana::type_c&lt;int&gt;) == hana::type_c&lt;int&gt;);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::just(std::string{<span class="stringliteral">&quot;abcd&quot;</span>})-&gt;<a class="code" href="group__group-Foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">size</a>() == 4);</div><div class="line"></div><div class="line"> <span class="comment">// hana::nothing.value(); // compile-time error</span></div><div class="line">}</div></div><!-- fragment -->
  540. </div>
  541. </div>
  542. <a id="a237b2147dd9b72bb2dfa4a268056e4c2"></a>
  543. <h2 class="memtitle"><span class="permalink"><a href="#a237b2147dd9b72bb2dfa4a268056e4c2">&#9670;&nbsp;</a></span>operator *()</h2>
  544. <div class="memitem">
  545. <div class="memproto">
  546. <div class="memtemplate">
  547. template&lt;typename ... T&gt; </div>
  548. <table class="memname">
  549. <tr>
  550. <td class="memname">constexpr T&amp; <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::operator * </td>
  551. <td>(</td>
  552. <td class="paramname"></td><td>)</td>
  553. <td></td>
  554. </tr>
  555. </table>
  556. </div><div class="memdoc">
  557. <p>Equivalent to <code><a class="el" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58" title="Extract the content of an optional, or fail at compile-time.">value()</a></code>, provided for convenience. </p>
  558. <dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for the cases where <code>*this</code> is a reference, a rvalue-reference and their <code>const</code> counterparts.</dd></dl>
  559. <h2>Example </h2>
  560. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>).<a class="code" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a>() == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(*hana::just(hana::type_c&lt;int&gt;) == hana::type_c&lt;int&gt;);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::just(std::string{<span class="stringliteral">&quot;abcd&quot;</span>})-&gt;<a class="code" href="group__group-Foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">size</a>() == 4);</div><div class="line"></div><div class="line"> <span class="comment">// hana::nothing.value(); // compile-time error</span></div><div class="line">}</div></div><!-- fragment -->
  561. </div>
  562. </div>
  563. <a id="a1f511267d94c178e4ef955da60f0888d"></a>
  564. <h2 class="memtitle"><span class="permalink"><a href="#a1f511267d94c178e4ef955da60f0888d">&#9670;&nbsp;</a></span>value_or()</h2>
  565. <div class="memitem">
  566. <div class="memproto">
  567. <div class="memtemplate">
  568. template&lt;typename ... T&gt; </div>
  569. <div class="memtemplate">
  570. template&lt;typename U &gt; </div>
  571. <table class="memname">
  572. <tr>
  573. <td class="memname">decltype(auto) constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::value_or </td>
  574. <td>(</td>
  575. <td class="paramtype">U &amp;&amp;&#160;</td>
  576. <td class="paramname"><em>default_</em></td><td>)</td>
  577. <td></td>
  578. </tr>
  579. </table>
  580. </div><div class="memdoc">
  581. <p>Return the contents of an <code>optional</code>, with a fallback result. </p>
  582. <p>If <code>*this</code> contains a value, that value is returned. Otherwise, the default value provided is returned.</p>
  583. <dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for the cases where <code>*this</code> is a reference, a rvalue-reference and their <code>const</code> counterparts.</dd></dl>
  584. <dl class="params"><dt>Parameters</dt><dd>
  585. <table class="params">
  586. <tr><td class="paramname"><a class="el" href="structboost_1_1hana_1_1default__.html" title="Mark a tag-dispatched method implementation as a default implementation.">default_</a></td><td>The default value to return if <code>*this</code> does not contain a value.</td></tr>
  587. </table>
  588. </dd>
  589. </dl>
  590. <h2>Example </h2>
  591. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line">static_assert(hana::just(1).<a class="code" href="structboost_1_1hana_1_1optional.html#a1f511267d94c178e4ef955da60f0888d">value_or</a>(<span class="charliteral">&#39;x&#39;</span>) == 1, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::nothing.<a class="code" href="structboost_1_1hana_1_1optional.html#a1f511267d94c178e4ef955da60f0888d">value_or</a>(<span class="charliteral">&#39;x&#39;</span>) == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  592. </div>
  593. </div>
  594. </div><!-- contents -->
  595. </div><!-- doc-content -->
  596. <!--
  597. Copyright Louis Dionne 2013-2017
  598. Distributed under the Boost Software License, Version 1.0.
  599. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  600. -->
  601. <!-- boost-no-inspect -->
  602. <!-- HTML footer for doxygen 1.8.9.1-->
  603. <!-- start footer part -->
  604. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  605. <ul>
  606. <li class="navelem"><b>boost</b></li><li class="navelem"><a class="el" href="namespaceboost_1_1hana.html">hana</a></li><li class="navelem"><a class="el" href="structboost_1_1hana_1_1optional.html">optional</a></li>
  607. </ul>
  608. </div>
  609. </body>
  610. </html>