group__group-Functor.html 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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: Functor</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('group__group-Functor.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="#var-members">Variables</a> </div>
  130. <div class="headertitle">
  131. <div class="title">Functor<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div> </div>
  132. </div><!--header-->
  133. <div class="contents">
  134. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  135. <p>The <code>Functor</code> concept represents types that can be mapped over. </p>
  136. <p>Intuitively, a <a href="http://en.wikipedia.org/wiki/Functor">Functor</a> is some kind of box that can hold generic data and map a function over this data to create a new, transformed box. Because we are only interested in mapping a function over the contents of a black box, the only real requirement for being a functor is to provide a function which can do the mapping, along with a couple of guarantees that the mapping is well-behaved. Those requirements are made precise in the laws below. The pattern captured by <code>Functor</code> is very general, which makes it widely useful. A lot of objects can be made <code>Functor</code>s in one way or another, the most obvious example being sequences with the usual mapping of the function on each element. While this documentation will not go into much more details about the nature of functors, the <a href="https://wiki.haskell.org/Typeclassopedia#Functor">Typeclassopedia</a> is a nice Haskell-oriented resource for such information.</p>
  137. <p>Functors are parametric data types which are parameterized over the data type of the objects they contain. Like everywhere else in Hana, this parametricity is only at the documentation level and it is not enforced.</p>
  138. <p>In this library, the mapping function is called <code>transform</code> after the <code>std::transform</code> algorithm, but other programming languages have given it different names (usually <code>map</code>).</p>
  139. <dl class="section note"><dt>Note</dt><dd>The word <em>functor</em> comes from functional programming, where the concept has been used for a while, notably in the Haskell programming language. Haskell people borrowed the term from <a href="http://en.wikipedia.org/wiki/Category_theory">category theory</a>, which, broadly speaking, is a field of mathematics dealing with abstract structures and transformations between those structures.</dd></dl>
  140. <h2>Minimal complete definitions </h2>
  141. <ol type="1">
  142. <li><code>transform</code><br />
  143. When <code>transform</code> is specified, <code>adjust_if</code> is defined analogously to <div class="fragment"><div class="line"><a class="code" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">adjust_if</a>(xs, pred, f) = <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, [](x){</div><div class="line"> <span class="keywordflow">if</span> pred(x) <a class="code" href="group__group-Monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> f(x) <span class="keywordflow">else</span> x</div><div class="line">})</div></div><!-- fragment --></li>
  144. <li><code>adjust_if</code><br />
  145. When <code>adjust_if</code> is specified, <code>transform</code> is defined analogously to <div class="fragment"><div class="line"><a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, f) = <a class="code" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">adjust_if</a>(xs, <a class="code" href="group__group-functional.html#ga835970cb25a0c8dc200f1e5f8943538b">always</a>(<span class="keyword">true</span>), f)</div></div><!-- fragment --></li>
  146. </ol>
  147. <h2>Laws </h2>
  148. <p>Let <code>xs</code> be a Functor with tag <code>F(A)</code>, \( f : A \to B \) and \( g : B \to C \). The following laws must be satisfied: </p><div class="fragment"><div class="line"><a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, <span class="keywordtype">id</span>) == xs</div><div class="line"><a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, <a class="code" href="group__group-functional.html#ga3b16146e53efcdf9ecbb9a7b21f8cd0b">compose</a>(g, f)) == <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(<a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, f), g)</div></div><!-- fragment --><p> The first line says that mapping the identity function should not do anything, which precludes the functor from doing something nasty behind the scenes. The second line states that mapping the composition of two functions is the same as mapping the first function, and then the second on the result. While the usual functor laws are usually restricted to the above, this library includes other convenience methods and they should satisfy the following equations. Let <code>xs</code> be a Functor with tag <code>F(A)</code>, \( f : A \to A \), \( \mathrm{pred} : A \to \mathrm{Bool} \) for some <code>Logical</code> <code>Bool</code>, and <code>oldval</code>, <code>newval</code>, <code>value</code> objects of tag <code>A</code>. Then, </p><div class="fragment"><div class="line"><a class="code" href="group__group-Functor.html#ga7cc731e67ebc1f5303be1a97b2d5e0cd">adjust</a>(xs, <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, f) == <a class="code" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">adjust_if</a>(xs, <a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">equal</a>.to(<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>), f)</div><div class="line"><a class="code" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">adjust_if</a>(xs, pred, f) == <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, [](x){</div><div class="line"> <span class="keywordflow">if</span> pred(x) <a class="code" href="group__group-Monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> f(x) <span class="keywordflow">else</span> x</div><div class="line">})</div><div class="line"><a class="code" href="group__group-Functor.html#ga1d21b4bccd16367d164fbe0d9ef52150">replace_if</a>(xs, pred, <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>) == <a class="code" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">adjust_if</a>(xs, pred, <a class="code" href="group__group-functional.html#ga835970cb25a0c8dc200f1e5f8943538b">always</a>(<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>))</div><div class="line"><a class="code" href="group__group-Functor.html#ga94cd3a75d59d70d77cfce144c4acf8ab">replace</a>(xs, oldval, newval) == <a class="code" href="group__group-Functor.html#ga1d21b4bccd16367d164fbe0d9ef52150">replace_if</a>(xs, <a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">equal</a>.to(oldval), newval)</div><div class="line"><a class="code" href="group__group-Functor.html#ga2ce68d315f981ef35751c4dc25ad5642">fill</a>(xs, <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>) == <a class="code" href="group__group-Functor.html#ga1d21b4bccd16367d164fbe0d9ef52150">replace_if</a>(xs, <a class="code" href="group__group-functional.html#ga835970cb25a0c8dc200f1e5f8943538b">always</a>(<span class="keyword">true</span>), <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>)</div></div><!-- fragment --><p> The default definition of the methods will satisfy these equations.</p>
  149. <h2>Concrete models </h2>
  150. <p><code><a class="el" href="structboost_1_1hana_1_1lazy.html" title="hana::lazy implements superficial laziness via a monadic interface.">hana::lazy</a></code>, <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>, <code><a class="el" href="structboost_1_1hana_1_1tuple.html" title="General purpose index-based heterogeneous sequence with a fixed length.">hana::tuple</a></code></p>
  151. <h2>Structure-preserving functions for Functors </h2>
  152. <p>A mapping between two functors which also preserves the functor laws is called a natural transformation (the term comes from category theory). A natural transformation is a function <code>f</code> from a functor <code>F</code> to a functor <code>G</code> such that for every other function <code>g</code> with an appropriate signature and for every object <code>xs</code> of tag <code>F(X)</code>, </p><div class="fragment"><div class="line">f(<a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(xs, g)) == <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(f(xs), g)</div></div><!-- fragment --><p>There are several examples of such transformations, like <code>to&lt;<a class="el" href="structboost_1_1hana_1_1tuple__tag.html" title="Tag representing hana::tuples.">tuple_tag</a>&gt;</code> when applied to an optional value. Indeed, for any function <code>g</code> and <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> <code>opt</code>, </p><div class="fragment"><div class="line">to&lt;tuple_tag&gt;(<a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(opt, g)) == <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">transform</a>(to&lt;tuple_tag&gt;(opt), g)</div></div><!-- fragment --><p>Of course, natural transformations are not limited to the <code>to&lt;...&gt;</code> functions. However, note that any conversion function between Functors should be natural for the behavior of the conversion to be intuitive. </p>
  153. <table class="memberdecls">
  154. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
  155. Variables</h2></td></tr>
  156. <tr class="memitem:ga7cc731e67ebc1f5303be1a97b2d5e0cd"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Functor.html#ga7cc731e67ebc1f5303be1a97b2d5e0cd">boost::hana::adjust</a></td></tr>
  157. <tr class="memdesc:ga7cc731e67ebc1f5303be1a97b2d5e0cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a function on all the elements of a structure that compare equal to some value. <a href="group__group-Functor.html#ga7cc731e67ebc1f5303be1a97b2d5e0cd">More...</a><br /></td></tr>
  158. <tr class="separator:ga7cc731e67ebc1f5303be1a97b2d5e0cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
  159. <tr class="memitem:gaa0490f57047c1b0d75fbe233688358f4"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">boost::hana::adjust_if</a></td></tr>
  160. <tr class="memdesc:gaa0490f57047c1b0d75fbe233688358f4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a function on all the elements of a structure satisfying a predicate.Given a Functor, a predicate <code>pred</code> and a function <code>f</code>, <code>adjust_if</code> will <em>adjust</em> the elements of the Functor that satisfy the predicate with the function <code>f</code>. In other words, <code>adjust_if</code> will return a new Functor equal to the original one, except that the elements satisfying the predicate will be transformed with the given function. Elements for which the predicate is not satisfied are left untouched, and they are kept as-is in the resulting Functor. <a href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">More...</a><br /></td></tr>
  161. <tr class="separator:gaa0490f57047c1b0d75fbe233688358f4"><td class="memSeparator" colspan="2">&#160;</td></tr>
  162. <tr class="memitem:ga2ce68d315f981ef35751c4dc25ad5642"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Functor.html#ga2ce68d315f981ef35751c4dc25ad5642">boost::hana::fill</a></td></tr>
  163. <tr class="memdesc:ga2ce68d315f981ef35751c4dc25ad5642"><td class="mdescLeft">&#160;</td><td class="mdescRight">Replace all the elements of a structure with a fixed value. <a href="group__group-Functor.html#ga2ce68d315f981ef35751c4dc25ad5642">More...</a><br /></td></tr>
  164. <tr class="separator:ga2ce68d315f981ef35751c4dc25ad5642"><td class="memSeparator" colspan="2">&#160;</td></tr>
  165. <tr class="memitem:ga94cd3a75d59d70d77cfce144c4acf8ab"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Functor.html#ga94cd3a75d59d70d77cfce144c4acf8ab">boost::hana::replace</a></td></tr>
  166. <tr class="memdesc:ga94cd3a75d59d70d77cfce144c4acf8ab"><td class="mdescLeft">&#160;</td><td class="mdescRight">Replace all the elements of a structure that compare equal to some <code>value</code> with some new fixed value. <a href="group__group-Functor.html#ga94cd3a75d59d70d77cfce144c4acf8ab">More...</a><br /></td></tr>
  167. <tr class="separator:ga94cd3a75d59d70d77cfce144c4acf8ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
  168. <tr class="memitem:ga1d21b4bccd16367d164fbe0d9ef52150"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Functor.html#ga1d21b4bccd16367d164fbe0d9ef52150">boost::hana::replace_if</a></td></tr>
  169. <tr class="memdesc:ga1d21b4bccd16367d164fbe0d9ef52150"><td class="mdescLeft">&#160;</td><td class="mdescRight">Replace all the elements of a structure satisfying a <code>predicate</code> with a fixed value. <a href="group__group-Functor.html#ga1d21b4bccd16367d164fbe0d9ef52150">More...</a><br /></td></tr>
  170. <tr class="separator:ga1d21b4bccd16367d164fbe0d9ef52150"><td class="memSeparator" colspan="2">&#160;</td></tr>
  171. <tr class="memitem:ga5a8975f6e55375d5b6038a9c36ee63e7"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">boost::hana::transform</a></td></tr>
  172. <tr class="memdesc:ga5a8975f6e55375d5b6038a9c36ee63e7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Map a function over a <code>Functor</code>. <a href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">More...</a><br /></td></tr>
  173. <tr class="separator:ga5a8975f6e55375d5b6038a9c36ee63e7"><td class="memSeparator" colspan="2">&#160;</td></tr>
  174. </table>
  175. <h2 class="groupheader">Variable Documentation</h2>
  176. <a id="ga7cc731e67ebc1f5303be1a97b2d5e0cd"></a>
  177. <h2 class="memtitle"><span class="permalink"><a href="#ga7cc731e67ebc1f5303be1a97b2d5e0cd">&#9670;&nbsp;</a></span>adjust</h2>
  178. <div class="memitem">
  179. <div class="memproto">
  180. <table class="memname">
  181. <tr>
  182. <td class="memname">constexpr auto boost::hana::adjust</td>
  183. </tr>
  184. </table>
  185. </div><div class="memdoc">
  186. <p><code>#include &lt;<a class="el" href="fwd_2adjust_8hpp.html">boost/hana/fwd/adjust.hpp</a>&gt;</code></p>
  187. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; xs, <span class="keyword">auto</span>&amp;&amp; <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="keyword">auto</span>&amp;&amp; f) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div><div class="ttc" id="group__group-Constant_html_ga1687520692a6b0c49e3a69de2980f388"><div class="ttname"><a href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">boost::hana::value</a></div><div class="ttdeci">constexpr auto value</div><div class="ttdoc">Return the compile-time value associated to a constant.This function returns the value associated to ...</div><div class="ttdef"><b>Definition:</b> value.hpp:54</div></div>
  188. </div><!-- fragment -->
  189. <p>Apply a function on all the elements of a structure that compare equal to some value. </p>
  190. <h2>Signature </h2>
  191. <p>Given <code>F</code> a Functor and <code>U</code> a type that can be compared with <code>T</code>'s, the signature is \( \mathtt{adjust} : F(T) \times U \times (T \to T) \to F(T) \)</p>
  192. <dl class="params"><dt>Parameters</dt><dd>
  193. <table class="params">
  194. <tr><td class="paramname">xs</td><td>The structure to adjust with <code>f</code>.</td></tr>
  195. <tr><td class="paramname">value</td><td>An object that is compared with each element <code>x</code> of the structure. Elements of the structure that compare equal to <code>value</code> are adjusted with the <code>f</code> function.</td></tr>
  196. <tr><td class="paramname">f</td><td>A function called as <code>f(x)</code> on the element(s) of the structure that compare equal to <code>value</code>.</td></tr>
  197. </table>
  198. </dd>
  199. </dl>
  200. <h2>Example </h2>
  201. <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="adjust_8hpp.html">boost/hana/adjust.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="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="tuple_8hpp.html">boost/hana/tuple.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">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a> = [](<span class="keyword">auto</span> x) {</div><div class="line"> <span class="keywordflow">return</span> -x;</div><div class="line">};</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>(</div><div class="line"> <a class="code" href="group__group-Functor.html#ga7cc731e67ebc1f5303be1a97b2d5e0cd">hana::adjust</a>(hana::make_tuple(1, 4, 9, 2, 3, 4), 4, <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>)</div><div class="line"> ==</div><div class="line"> hana::make_tuple(1, -4, 9, 2, 3, -4)</div><div class="line"> );</div><div class="line">}</div></div><!-- fragment -->
  202. </div>
  203. </div>
  204. <a id="gaa0490f57047c1b0d75fbe233688358f4"></a>
  205. <h2 class="memtitle"><span class="permalink"><a href="#gaa0490f57047c1b0d75fbe233688358f4">&#9670;&nbsp;</a></span>adjust_if</h2>
  206. <div class="memitem">
  207. <div class="memproto">
  208. <table class="memname">
  209. <tr>
  210. <td class="memname">constexpr auto boost::hana::adjust_if</td>
  211. </tr>
  212. </table>
  213. </div><div class="memdoc">
  214. <p><code>#include &lt;<a class="el" href="fwd_2adjust__if_8hpp.html">boost/hana/fwd/adjust_if.hpp</a>&gt;</code></p>
  215. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; xs, <span class="keyword">auto</span> <span class="keyword">const</span>&amp; pred, <span class="keyword">auto</span> <span class="keyword">const</span>&amp; f) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  216. <p>Apply a function on all the elements of a structure satisfying a predicate.Given a Functor, a predicate <code>pred</code> and a function <code>f</code>, <code>adjust_if</code> will <em>adjust</em> the elements of the Functor that satisfy the predicate with the function <code>f</code>. In other words, <code>adjust_if</code> will return a new Functor equal to the original one, except that the elements satisfying the predicate will be transformed with the given function. Elements for which the predicate is not satisfied are left untouched, and they are kept as-is in the resulting Functor. </p>
  217. <h2>Signature </h2>
  218. <p>Given a <code>Functor</code> <code>F</code> and a <code>Logical</code> <code>Bool</code>, the signature is \( \mathtt{adjust\_if} : F(T) \times (T \to Bool) \times (T \to T) \to F(T) \)</p>
  219. <dl class="params"><dt>Parameters</dt><dd>
  220. <table class="params">
  221. <tr><td class="paramname">xs</td><td>The structure to adjust with <code>f</code>.</td></tr>
  222. <tr><td class="paramname">pred</td><td>A function called as <code>pred(x)</code> for each element of the Functor, and returning whether <code>f</code> should be applied on that element.</td></tr>
  223. <tr><td class="paramname">f</td><td>A function called as <code>f(x)</code> on the element(s) of the Functor that satisfy the predicate.</td></tr>
  224. </table>
  225. </dd>
  226. </dl>
  227. <h2>Example </h2>
  228. <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="adjust__if_8hpp.html">boost/hana/adjust_if.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="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="tuple_8hpp.html">boost/hana/tuple.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">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> negative = [](<span class="keyword">auto</span> x) {</div><div class="line"> <span class="keywordflow">return</span> x &lt; 0;</div><div class="line">};</div><div class="line"></div><div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a> = [](<span class="keyword">auto</span> x) {</div><div class="line"> <span class="keywordflow">return</span> -x;</div><div class="line">};</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>(</div><div class="line"> <a class="code" href="group__group-Functor.html#gaa0490f57047c1b0d75fbe233688358f4">hana::adjust_if</a>(hana::make_tuple(-3, -2, -1, 0, 1, 2, 3), negative, <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>)</div><div class="line"> ==</div><div class="line"> hana::make_tuple(3, 2, 1, 0, 1, 2, 3)</div><div class="line"> );</div><div class="line">}</div></div><!-- fragment -->
  229. </div>
  230. </div>
  231. <a id="ga2ce68d315f981ef35751c4dc25ad5642"></a>
  232. <h2 class="memtitle"><span class="permalink"><a href="#ga2ce68d315f981ef35751c4dc25ad5642">&#9670;&nbsp;</a></span>fill</h2>
  233. <div class="memitem">
  234. <div class="memproto">
  235. <table class="memname">
  236. <tr>
  237. <td class="memname">constexpr auto boost::hana::fill</td>
  238. </tr>
  239. </table>
  240. </div><div class="memdoc">
  241. <p><code>#include &lt;<a class="el" href="fwd_2fill_8hpp.html">boost/hana/fwd/fill.hpp</a>&gt;</code></p>
  242. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; xs, <span class="keyword">auto</span>&amp;&amp; <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div><div class="ttc" id="group__group-Constant_html_ga1687520692a6b0c49e3a69de2980f388"><div class="ttname"><a href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">boost::hana::value</a></div><div class="ttdeci">constexpr auto value</div><div class="ttdoc">Return the compile-time value associated to a constant.This function returns the value associated to ...</div><div class="ttdef"><b>Definition:</b> value.hpp:54</div></div>
  243. </div><!-- fragment -->
  244. <p>Replace all the elements of a structure with a fixed value. </p>
  245. <h2>Signature </h2>
  246. <p>Given <code>F</code> a Functor, the signature is \( \mathtt{fill} : F(T) \times U \to F(U) \)</p>
  247. <dl class="params"><dt>Parameters</dt><dd>
  248. <table class="params">
  249. <tr><td class="paramname">xs</td><td>The structure to fill with a <code>value</code>.</td></tr>
  250. <tr><td class="paramname">value</td><td>A value by which every element <code>x</code> of the structure is replaced, unconditionally.</td></tr>
  251. </table>
  252. </dd>
  253. </dl>
  254. <h2>Example </h2>
  255. <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="fill_8hpp.html">boost/hana/fill.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="tuple_8hpp.html">boost/hana/tuple.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"> static_assert(</div><div class="line"> <a class="code" href="group__group-Functor.html#ga2ce68d315f981ef35751c4dc25ad5642">hana::fill</a>(hana::make_tuple(1, <span class="charliteral">&#39;2&#39;</span>, 3.3, <span class="keyword">nullptr</span>), <span class="charliteral">&#39;x&#39;</span>)</div><div class="line"> ==</div><div class="line"> hana::make_tuple(<span class="charliteral">&#39;x&#39;</span>, <span class="charliteral">&#39;x&#39;</span>, <span class="charliteral">&#39;x&#39;</span>, <span class="charliteral">&#39;x&#39;</span>)</div><div class="line"> , <span class="stringliteral">&quot;&quot;</span>);</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#ga2ce68d315f981ef35751c4dc25ad5642">hana::fill</a>(hana::nothing, <span class="charliteral">&#39;x&#39;</span>) == hana::nothing);</div><div class="line"> static_assert(<a class="code" href="group__group-Functor.html#ga2ce68d315f981ef35751c4dc25ad5642">hana::fill</a>(hana::just(<span class="charliteral">&#39;y&#39;</span>), <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">}</div></div><!-- fragment -->
  256. </div>
  257. </div>
  258. <a id="ga94cd3a75d59d70d77cfce144c4acf8ab"></a>
  259. <h2 class="memtitle"><span class="permalink"><a href="#ga94cd3a75d59d70d77cfce144c4acf8ab">&#9670;&nbsp;</a></span>replace</h2>
  260. <div class="memitem">
  261. <div class="memproto">
  262. <table class="memname">
  263. <tr>
  264. <td class="memname">constexpr auto boost::hana::replace</td>
  265. </tr>
  266. </table>
  267. </div><div class="memdoc">
  268. <p><code>#include &lt;<a class="el" href="fwd_2replace_8hpp.html">boost/hana/fwd/replace.hpp</a>&gt;</code></p>
  269. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; xs, <span class="keyword">auto</span>&amp;&amp; oldval, <span class="keyword">auto</span>&amp;&amp; newval) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  270. <p>Replace all the elements of a structure that compare equal to some <code>value</code> with some new fixed value. </p>
  271. <h2>Signature </h2>
  272. <p>Given <code>F</code> a Functor and <code>U</code> a type that can be compared with <code>T</code>, the signature is \( \mathtt{replace} : F(T) \times U \times T \to F(T) \)</p>
  273. <dl class="params"><dt>Parameters</dt><dd>
  274. <table class="params">
  275. <tr><td class="paramname">xs</td><td>The structure to replace elements of.</td></tr>
  276. <tr><td class="paramname">oldval</td><td>An object compared with each element of the structure. Elements of the structure that compare equal to <code>oldval</code> are replaced by <code>newval</code> in the new structure.</td></tr>
  277. <tr><td class="paramname">newval</td><td>A value by which every element <code>x</code> of the structure that compares equal to <code>oldval</code> is replaced.</td></tr>
  278. </table>
  279. </dd>
  280. </dl>
  281. <h2>Example </h2>
  282. <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="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="replace_8hpp.html">boost/hana/replace.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.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(</div><div class="line"> <a class="code" href="group__group-Functor.html#ga94cd3a75d59d70d77cfce144c4acf8ab">hana::replace</a>(hana::make_tuple(1, 1, 1, 2, 3, 1, 4, 5), 1, 0)</div><div class="line"> ==</div><div class="line"> hana::make_tuple(0, 0, 0, 2, 3, 0, 4, 5)</div><div class="line">, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  283. </div>
  284. </div>
  285. <a id="ga1d21b4bccd16367d164fbe0d9ef52150"></a>
  286. <h2 class="memtitle"><span class="permalink"><a href="#ga1d21b4bccd16367d164fbe0d9ef52150">&#9670;&nbsp;</a></span>replace_if</h2>
  287. <div class="memitem">
  288. <div class="memproto">
  289. <table class="memname">
  290. <tr>
  291. <td class="memname">constexpr auto boost::hana::replace_if</td>
  292. </tr>
  293. </table>
  294. </div><div class="memdoc">
  295. <p><code>#include &lt;<a class="el" href="fwd_2replace__if_8hpp.html">boost/hana/fwd/replace_if.hpp</a>&gt;</code></p>
  296. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; xs, <span class="keyword">auto</span>&amp;&amp; predicate, <span class="keyword">auto</span>&amp;&amp; <a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div><div class="ttc" id="group__group-Constant_html_ga1687520692a6b0c49e3a69de2980f388"><div class="ttname"><a href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">boost::hana::value</a></div><div class="ttdeci">constexpr auto value</div><div class="ttdoc">Return the compile-time value associated to a constant.This function returns the value associated to ...</div><div class="ttdef"><b>Definition:</b> value.hpp:54</div></div>
  297. </div><!-- fragment -->
  298. <p>Replace all the elements of a structure satisfying a <code>predicate</code> with a fixed value. </p>
  299. <h2>Signature </h2>
  300. <p>Given <code>F</code> a Functor and <code>Bool</code> a Logical, the signature is \( \mathtt{replace\_if} : F(T) \times (T \to Bool) \times T \to F(T) \)</p>
  301. <dl class="params"><dt>Parameters</dt><dd>
  302. <table class="params">
  303. <tr><td class="paramname">xs</td><td>The structure to replace elements of.</td></tr>
  304. <tr><td class="paramname">predicate</td><td>A function called as <code>predicate(x)</code> for element(s) <code>x</code> of the structure and returning a <code>Logical</code> representing whether <code>x</code> should be replaced by <code>value</code>.</td></tr>
  305. <tr><td class="paramname">value</td><td>A value by which every element <code>x</code> of the structure for which <code>predicate</code> returns a true-valued <code>Logical</code> is replaced.</td></tr>
  306. </table>
  307. </dd>
  308. </dl>
  309. <h2>Example </h2>
  310. <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="replace__if_8hpp.html">boost/hana/replace_if.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.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">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> negative = [](<span class="keyword">auto</span> x) {</div><div class="line"> <span class="keywordflow">return</span> x &lt; 0;</div><div class="line">};</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>(</div><div class="line"> <a class="code" href="group__group-Functor.html#ga1d21b4bccd16367d164fbe0d9ef52150">hana::replace_if</a>(hana::make_tuple(-3, -2, -1, 0, 1, 2, 3), negative, 0)</div><div class="line"> ==</div><div class="line"> hana::make_tuple(0, 0, 0, 0, 1, 2, 3)</div><div class="line"> );</div><div class="line">}</div></div><!-- fragment -->
  311. </div>
  312. </div>
  313. <a id="ga5a8975f6e55375d5b6038a9c36ee63e7"></a>
  314. <h2 class="memtitle"><span class="permalink"><a href="#ga5a8975f6e55375d5b6038a9c36ee63e7">&#9670;&nbsp;</a></span>transform</h2>
  315. <div class="memitem">
  316. <div class="memproto">
  317. <table class="memname">
  318. <tr>
  319. <td class="memname">constexpr auto boost::hana::transform</td>
  320. </tr>
  321. </table>
  322. </div><div class="memdoc">
  323. <p><code>#include &lt;<a class="el" href="fwd_2transform_8hpp.html">boost/hana/fwd/transform.hpp</a>&gt;</code></p>
  324. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; xs, <span class="keyword">auto</span>&amp;&amp; f) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  325. <p>Map a function over a <code>Functor</code>. </p>
  326. <h2>Signature </h2>
  327. <p>Given <code>F</code> a Functor, the signature is \( \mathtt{transform} : F(T) \times (T \to U) \to F(U) \)</p>
  328. <dl class="params"><dt>Parameters</dt><dd>
  329. <table class="params">
  330. <tr><td class="paramname">xs</td><td>The structure to map <code>f</code> over.</td></tr>
  331. <tr><td class="paramname">f</td><td>A function called as <code>f(x)</code> on element(s) <code>x</code> of the structure, and returning a new value to replace <code>x</code> in the structure.</td></tr>
  332. </table>
  333. </dd>
  334. </dl>
  335. <h2>Example </h2>
  336. <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="transform_8hpp.html">boost/hana/transform.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.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;sstream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;type_traits&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"><span class="keyword">using namespace </span>std::literals;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">auto</span> to_string = [](<span class="keyword">auto</span> x) {</div><div class="line"> std::ostringstream ss;</div><div class="line"> ss &lt;&lt; x;</div><div class="line"> <span class="keywordflow">return</span> ss.str();</div><div class="line">};</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#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(</div><div class="line"> <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">hana::transform</a>(hana::make_tuple(1, <span class="charliteral">&#39;2&#39;</span>, <span class="stringliteral">&quot;345&quot;</span>, std::string{<span class="stringliteral">&quot;67&quot;</span>}), to_string)</div><div class="line"> ==</div><div class="line"> hana::make_tuple(<span class="stringliteral">&quot;1&quot;</span>, <span class="stringliteral">&quot;2&quot;</span>, <span class="stringliteral">&quot;345&quot;</span>, <span class="stringliteral">&quot;67&quot;</span>)</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, to_string) == hana::nothing);</div><div class="line"> <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">hana::transform</a>(hana::just(123), to_string) == hana::just(<span class="stringliteral">&quot;123&quot;</span>s));</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"> <a class="code" href="group__group-Functor.html#ga5a8975f6e55375d5b6038a9c36ee63e7">hana::transform</a>(hana::tuple_t&lt;<span class="keywordtype">void</span>, <span class="keywordtype">int</span>(), <span class="keywordtype">char</span>[10]&gt;, hana::metafunction&lt;std::add_pointer&gt;)</div><div class="line"> ==</div><div class="line"> hana::tuple_t&lt;<span class="keywordtype">void</span>*, <span class="keywordtype">int</span>(*)(), <span class="keywordtype">char</span>(*)[10]&gt;</div><div class="line"> );</div><div class="line">}</div></div><!-- fragment -->
  337. </div>
  338. </div>
  339. </div><!-- contents -->
  340. </div><!-- doc-content -->
  341. <!--
  342. Copyright Louis Dionne 2013-2017
  343. Distributed under the Boost Software License, Version 1.0.
  344. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  345. -->
  346. <!-- boost-no-inspect -->
  347. <!-- HTML footer for doxygen 1.8.9.1-->
  348. <!-- start footer part -->
  349. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  350. <ul>
  351. </ul>
  352. </div>
  353. </body>
  354. </html>