group__group-Orderable.html 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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: Orderable</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-Orderable.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">Orderable<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>Orderable</code> concept represents totally ordered data types. </p>
  136. <p>Intuitively, <code>Orderable</code> objects must define a binary predicate named <code>less</code> returning whether the first argument is to be considered less than the second argument. The word "total" means that <em>distinct</em> objects must always be ordered; if <code>a</code> and <code>b</code> are not equal, then exactly one of <code>less(a, b)</code> and <code>less(b, a)</code> must be true. This is a contrast with weaker kinds of orders that would allow some objects to be incomparable (neither less than nor greater than). Also note that a non-strict total order may always be obtained from a strict total order (and vice-versa) by setting </p><div class="fragment"><div class="line">a &lt;= b = !(b &lt; a)</div><div class="line">a &lt; b = !(b &lt;= a)</div></div><!-- fragment --><p> The non-strict version is used in the description of the laws because it makes them easier to parse for humans, but they could be formulated equivalently using the strict order.</p>
  137. <h2>Minimal complete definition </h2>
  138. <p><code>less</code></p>
  139. <p>When <code>less</code> is defined, the other methods are defined from it using the same definition as mandated in the laws below.</p>
  140. <h2>Laws </h2>
  141. <p>Rigorously speaking, a <a href="http://en.wikipedia.org/wiki/Total_order">total order</a> <code>&lt;=</code> on a set <code>S</code> is a binary predicate \( &lt;= \;: S \times S \to bool \) such that for all <code>a</code>, <code>b</code>, <code>c</code> in <code>S</code>, </p><div class="fragment"><div class="line"><span class="keywordflow">if</span> a &lt;= b and b &lt;= a <a class="code" href="group__group-Monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> a == b <span class="comment">// Antisymmetry</span></div><div class="line"><span class="keywordflow">if</span> a &lt;= b and b &lt;= c <a class="code" href="group__group-Monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> a &lt;= c <span class="comment">// Transitivity</span></div><div class="line">either a &lt;= b or b &lt;= a <span class="comment">// Totality</span></div></div><!-- fragment --><p> Additionally, the <code>less</code>, <code>greater</code> and <code>greater_equal</code> methods should have the following intuitive meanings: </p><div class="fragment"><div class="line">a &lt; b <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> !(b &lt;= a)</div><div class="line">a &gt; b <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> b &lt; a</div><div class="line">a &gt;= b <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> !(a &lt; b)</div></div><!-- fragment --><h2>Refined concept </h2>
  142. <ol type="1">
  143. <li><code>Comparable</code> (free model)<br />
  144. Since <code>Orderable</code> requires <code>less_equal</code> to be a total order, a model of <code>Comparable</code> may always be obtained by setting <div class="fragment"><div class="line"><a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">equal</a>(x, y) = <a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(x, y) &amp;&amp; <a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(y, x)</div></div><!-- fragment --></li>
  145. </ol>
  146. <h2>Concrete models </h2>
  147. <p><code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">hana::integral_constant</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_1pair.html" title="Generic container for two elements.">hana::pair</a></code>, <code><a class="el" href="structboost_1_1hana_1_1string.html" title="Compile-time string.">hana::string</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>
  148. <h2>Free model for <code>LessThanComparable</code> data types </h2>
  149. <p>Two data types <code>T</code> and <code>U</code> that model the cross-type version of the usual <a href="http://en.cppreference.com/w/cpp/named_req/LessThanComparable">LessThanComparable</a> C++ concept are automatically a model of <code>Orderable</code> by setting </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(x, y) = (x &lt; y)</div></div><!-- fragment --><p> The cross-type version of the LessThanComparable concept is analogous to the cross-type version of the EqualityComparable concept presented in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3351.pdf">N3351</a>, which is compatible with the usual single type definition. However, note that the LessThanComparable concept only requires <code>&lt;</code> to be a <a href="http://en.wikipedia.org/wiki/Strict_weak_ordering">strict weak ordering</a>, which is a weaker requirement than being a total order. Hence, if <code>less</code> is used with objects of a LessThanComparable data type that do not define a total order, some algorithms may have an unexpected behavior. It is the author's opinion that defining <code>operator&lt;</code> as a non-total order is a bad idea, but this is debatable and so the design choice of providing a model for LessThanComparable data types is open to debate. Waiting for some user input.</p>
  150. <h2>Order-preserving functions </h2>
  151. <p>Let <code>A</code> and <code>B</code> be two <code>Orderable</code> data types. A function \( f : A \to B\) is said to be order-preserving (also called monotone) if it preserves the structure of the <code>Orderable</code> concept, which can be rigorously stated as follows. For all objects <code>x</code>, <code>y</code> of data type <code>A</code>, </p><div class="fragment"><div class="line"><span class="keywordflow">if</span> <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(x, y) <a class="code" href="group__group-Monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(f(x), f(y))</div></div><!-- fragment --><p> Another important property is that of being order-reflecting, which can be stated as </p><div class="fragment"><div class="line"><span class="keywordflow">if</span> <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(f(x), f(y)) <a class="code" href="group__group-Monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(x, y)</div></div><!-- fragment --><p> We say that a function is an order-embedding if it is both order-preserving and order-reflecting, i.e. if </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(x, y) <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(f(x), f(y))</div></div><!-- fragment --><h2>Cross-type version of the methods </h2>
  152. <p>The comparison methods (<code>less</code>, <code>less_equal</code>, <code>greater</code> and <code>greater_equal</code>) are "overloaded" to handle distinct data types with certain properties. Specifically, they are defined for <em>distinct</em> data types <code>A</code> and <code>B</code> such that</p><ol type="1">
  153. <li><code>A</code> and <code>B</code> share a common data type <code>C</code>, as determined by the <code>common</code> metafunction</li>
  154. <li><code>A</code>, <code>B</code> and <code>C</code> are all <code>Orderable</code> when taken individually</li>
  155. <li>\(\mathrm{to&lt;C&gt;} : A \to C\) and \(\mathrm{to&lt;C&gt;} : B \to C\) are both order-embeddings as determined by the <code>is_embedding</code> metafunction.</li>
  156. </ol>
  157. <p>The method definitions for data types satisfying the above properties are </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(x, y) = <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(to&lt;C&gt;(x), to&lt;C&gt;(y))</div><div class="line"><a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(x, y) = <a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(to&lt;C&gt;(x), to&lt;C&gt;(y))</div><div class="line"><a class="code" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">greater_equal</a>(x, y) = <a class="code" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">greater_equal</a>(to&lt;C&gt;(x), to&lt;C&gt;(y))</div><div class="line"><a class="code" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">greater</a>(x, y) = <a class="code" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">greater</a>(to&lt;C&gt;(x), to&lt;C&gt;(y))</div></div><!-- fragment --><h2>Partial application of the methods </h2>
  158. <p>The <code>less</code>, <code>greater</code>, <code>less_equal</code> and <code>greater_equal</code> methods can be called in two different ways. First, they can be called like normal functions: </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(x, y)</div><div class="line"><a class="code" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">greater</a>(x, y)</div><div class="line"></div><div class="line"><a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(x, y)</div><div class="line"><a class="code" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">greater_equal</a>(x, y)</div></div><!-- fragment --><p>However, they may also be partially applied to an argument as follows: </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>.than(x)(y) == <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(y, x)</div><div class="line"><a class="code" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">greater</a>.than(x)(y) == <a class="code" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">greater</a>(y, x)</div><div class="line"></div><div class="line"><a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>.than(x)(y) == <a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(y, x)</div><div class="line"><a class="code" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">greater_equal</a>.than(x)(y) == <a class="code" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">greater_equal</a>(y, x)</div></div><!-- fragment --><p>Take good note that the order of the arguments is reversed, so for example <code>less.than(x)(y)</code> is equivalent to <code>less(y, x)</code>, not <code>less(x, y)</code>. This is because those variants are meant to be used with higher order algorithms, where the chosen application order makes sense. </p>
  159. <table class="memberdecls">
  160. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
  161. Variables</h2></td></tr>
  162. <tr class="memitem:gaf9a073eafebbe514fb19dff82318f198"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">boost::hana::greater</a></td></tr>
  163. <tr class="memdesc:gaf9a073eafebbe514fb19dff82318f198"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Logical</code> representing whether <code>x</code> is greater than <code>y</code>. <a href="group__group-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">More...</a><br /></td></tr>
  164. <tr class="separator:gaf9a073eafebbe514fb19dff82318f198"><td class="memSeparator" colspan="2">&#160;</td></tr>
  165. <tr class="memitem:ga6023631e7d0a01e16dc3fa4221fbd703"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">boost::hana::greater_equal</a></td></tr>
  166. <tr class="memdesc:ga6023631e7d0a01e16dc3fa4221fbd703"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Logical</code> representing whether <code>x</code> is greater than or equal to <code>y</code>. <a href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">More...</a><br /></td></tr>
  167. <tr class="separator:ga6023631e7d0a01e16dc3fa4221fbd703"><td class="memSeparator" colspan="2">&#160;</td></tr>
  168. <tr class="memitem:gad510011602bdb14686f1c4ec145301c9"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">boost::hana::less</a></td></tr>
  169. <tr class="memdesc:gad510011602bdb14686f1c4ec145301c9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Logical</code> representing whether <code>x</code> is less than <code>y</code>. <a href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">More...</a><br /></td></tr>
  170. <tr class="separator:gad510011602bdb14686f1c4ec145301c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
  171. <tr class="memitem:ga9917dd82beb67151bf5657245d37b851"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">boost::hana::less_equal</a></td></tr>
  172. <tr class="memdesc:ga9917dd82beb67151bf5657245d37b851"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Logical</code> representing whether <code>x</code> is less than or equal to <code>y</code>. <a href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">More...</a><br /></td></tr>
  173. <tr class="separator:ga9917dd82beb67151bf5657245d37b851"><td class="memSeparator" colspan="2">&#160;</td></tr>
  174. <tr class="memitem:ga999eee8ca8750f9b1afa0d7a1db28030"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#ga999eee8ca8750f9b1afa0d7a1db28030">boost::hana::max</a></td></tr>
  175. <tr class="memdesc:ga999eee8ca8750f9b1afa0d7a1db28030"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the greatest of its arguments according to the <code>less</code> ordering. <a href="group__group-Orderable.html#ga999eee8ca8750f9b1afa0d7a1db28030">More...</a><br /></td></tr>
  176. <tr class="separator:ga999eee8ca8750f9b1afa0d7a1db28030"><td class="memSeparator" colspan="2">&#160;</td></tr>
  177. <tr class="memitem:ga2d54f189ea6f57fb2c0d772169440c5c"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#ga2d54f189ea6f57fb2c0d772169440c5c">boost::hana::min</a></td></tr>
  178. <tr class="memdesc:ga2d54f189ea6f57fb2c0d772169440c5c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the smallest of its arguments according to the <code>less</code> ordering. <a href="group__group-Orderable.html#ga2d54f189ea6f57fb2c0d772169440c5c">More...</a><br /></td></tr>
  179. <tr class="separator:ga2d54f189ea6f57fb2c0d772169440c5c"><td class="memSeparator" colspan="2">&#160;</td></tr>
  180. <tr class="memitem:gaf7e94ba859710cd6ba6152e5dc18977d"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">boost::hana::ordering</a></td></tr>
  181. <tr class="memdesc:gaf7e94ba859710cd6ba6152e5dc18977d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a function performing <code>less</code> after applying a transformation to both arguments.<code>ordering</code> creates a total order based on the result of applying a function to some objects, which is especially useful in conjunction with algorithms that accept a custom predicate that must represent a total order. <a href="group__group-Orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">More...</a><br /></td></tr>
  182. <tr class="separator:gaf7e94ba859710cd6ba6152e5dc18977d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  183. </table>
  184. <h2 class="groupheader">Variable Documentation</h2>
  185. <a id="gaf9a073eafebbe514fb19dff82318f198"></a>
  186. <h2 class="memtitle"><span class="permalink"><a href="#gaf9a073eafebbe514fb19dff82318f198">&#9670;&nbsp;</a></span>greater</h2>
  187. <div class="memitem">
  188. <div class="memproto">
  189. <table class="memname">
  190. <tr>
  191. <td class="memname">constexpr auto boost::hana::greater</td>
  192. </tr>
  193. </table>
  194. </div><div class="memdoc">
  195. <p><code>#include &lt;<a class="el" href="fwd_2greater_8hpp.html">boost/hana/fwd/greater.hpp</a>&gt;</code></p>
  196. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  197. <p>Returns a <code>Logical</code> representing whether <code>x</code> is greater than <code>y</code>. </p>
  198. <h2>Signature </h2>
  199. <p>Given a Logical <code>Bool</code> and two Orderables <code>A</code> and <code>B</code> with a common embedding, the signature is \( \mathrm{greater} : A \times B \to Bool \).</p>
  200. <dl class="params"><dt>Parameters</dt><dd>
  201. <table class="params">
  202. <tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
  203. </table>
  204. </dd>
  205. </dl>
  206. <h2>Example </h2>
  207. <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="integral__constant_8hpp.html">boost/hana/integral_constant.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-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">hana::greater</a>(4, 1), <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-Orderable.html#gaf9a073eafebbe514fb19dff82318f198">hana::greater</a>(hana::int_c&lt;1&gt;, hana::int_c&lt;3&gt;));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  208. </div>
  209. </div>
  210. <a id="ga6023631e7d0a01e16dc3fa4221fbd703"></a>
  211. <h2 class="memtitle"><span class="permalink"><a href="#ga6023631e7d0a01e16dc3fa4221fbd703">&#9670;&nbsp;</a></span>greater_equal</h2>
  212. <div class="memitem">
  213. <div class="memproto">
  214. <table class="memname">
  215. <tr>
  216. <td class="memname">constexpr auto boost::hana::greater_equal</td>
  217. </tr>
  218. </table>
  219. </div><div class="memdoc">
  220. <p><code>#include &lt;<a class="el" href="fwd_2greater__equal_8hpp.html">boost/hana/fwd/greater_equal.hpp</a>&gt;</code></p>
  221. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  222. <p>Returns a <code>Logical</code> representing whether <code>x</code> is greater than or equal to <code>y</code>. </p>
  223. <h2>Signature </h2>
  224. <p>Given a Logical <code>Bool</code> and two Orderables <code>A</code> and <code>B</code> with a common embedding, the signature is \( \mathrm{greater\_equal} : A \times B \to Bool \).</p>
  225. <dl class="params"><dt>Parameters</dt><dd>
  226. <table class="params">
  227. <tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
  228. </table>
  229. </dd>
  230. </dl>
  231. <h2>Example </h2>
  232. <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__equal_8hpp.html">boost/hana/greater_equal.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="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-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">hana::greater_equal</a>(4, 1), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(<a class="code" href="group__group-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">hana::greater_equal</a>(1, 1), <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-Orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">hana::greater_equal</a>(hana::int_c&lt;1&gt;, hana::int_c&lt;2&gt;));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  233. </div>
  234. </div>
  235. <a id="gad510011602bdb14686f1c4ec145301c9"></a>
  236. <h2 class="memtitle"><span class="permalink"><a href="#gad510011602bdb14686f1c4ec145301c9">&#9670;&nbsp;</a></span>less</h2>
  237. <div class="memitem">
  238. <div class="memproto">
  239. <table class="memname">
  240. <tr>
  241. <td class="memname">constexpr auto boost::hana::less</td>
  242. </tr>
  243. </table>
  244. </div><div class="memdoc">
  245. <p><code>#include &lt;<a class="el" href="fwd_2less_8hpp.html">boost/hana/fwd/less.hpp</a>&gt;</code></p>
  246. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  247. <p>Returns a <code>Logical</code> representing whether <code>x</code> is less than <code>y</code>. </p>
  248. <h2>Signature </h2>
  249. <p>Given a Logical <code>Bool</code> and two Orderables <code>A</code> and <code>B</code> with a common embedding, the signature is \( \mathrm{less} : A \times B \to Bool \).</p>
  250. <dl class="params"><dt>Parameters</dt><dd>
  251. <table class="params">
  252. <tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
  253. </table>
  254. </dd>
  255. </dl>
  256. <h2>Example </h2>
  257. <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="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="less_8hpp.html">boost/hana/less.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="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(<a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">hana::less</a>(1, 4), <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-Orderable.html#gad510011602bdb14686f1c4ec145301c9">hana::less</a>(hana::int_c&lt;3&gt;, hana::int_c&lt;2&gt;));</div><div class="line"></div><div class="line"><span class="comment">// less.than is syntactic sugar</span></div><div class="line">static_assert(<a class="code" href="group__group-Searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::tuple_c&lt;int, 1, 2, 3, 4&gt;, <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">hana::less</a>.than(5)), <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-Searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::tuple_c&lt;int, 1, 2, 3, 4&gt;, <a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">hana::less_equal</a>.than(hana::int_c&lt;4&gt;)));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  258. </div>
  259. </div>
  260. <a id="ga9917dd82beb67151bf5657245d37b851"></a>
  261. <h2 class="memtitle"><span class="permalink"><a href="#ga9917dd82beb67151bf5657245d37b851">&#9670;&nbsp;</a></span>less_equal</h2>
  262. <div class="memitem">
  263. <div class="memproto">
  264. <table class="memname">
  265. <tr>
  266. <td class="memname">constexpr auto boost::hana::less_equal</td>
  267. </tr>
  268. </table>
  269. </div><div class="memdoc">
  270. <p><code>#include &lt;<a class="el" href="fwd_2less__equal_8hpp.html">boost/hana/fwd/less_equal.hpp</a>&gt;</code></p>
  271. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  272. <p>Returns a <code>Logical</code> representing whether <code>x</code> is less than or equal to <code>y</code>. </p>
  273. <h2>Signature </h2>
  274. <p>Given a Logical <code>Bool</code> and two Orderables <code>A</code> and <code>B</code> with a common embedding, the signature is \( \mathrm{less\_equal} : A \times B \to Bool \).</p>
  275. <dl class="params"><dt>Parameters</dt><dd>
  276. <table class="params">
  277. <tr><td class="paramname">x,y</td><td>Two objects to compare.</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="assert_8hpp.html">boost/hana/assert.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="less__equal_8hpp.html">boost/hana/less_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="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-Orderable.html#ga9917dd82beb67151bf5657245d37b851">hana::less_equal</a>(1, 4), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(<a class="code" href="group__group-Orderable.html#ga9917dd82beb67151bf5657245d37b851">hana::less_equal</a>(1, 1), <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-Orderable.html#ga9917dd82beb67151bf5657245d37b851">hana::less_equal</a>(hana::int_c&lt;3&gt;, hana::int_c&lt;2&gt;));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  283. </div>
  284. </div>
  285. <a id="ga999eee8ca8750f9b1afa0d7a1db28030"></a>
  286. <h2 class="memtitle"><span class="permalink"><a href="#ga999eee8ca8750f9b1afa0d7a1db28030">&#9670;&nbsp;</a></span>max</h2>
  287. <div class="memitem">
  288. <div class="memproto">
  289. <table class="memname">
  290. <tr>
  291. <td class="memname">constexpr auto boost::hana::max</td>
  292. </tr>
  293. </table>
  294. </div><div class="memdoc">
  295. <p><code>#include &lt;<a class="el" href="fwd_2max_8hpp.html">boost/hana/fwd/max.hpp</a>&gt;</code></p>
  296. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  297. <p>Returns the greatest of its arguments according to the <code>less</code> ordering. </p>
  298. <dl class="todo"><dt><b><a class="el" href="todo.html#_todo000005">Todo:</a></b></dt><dd>Can't specify the signature here either. See <code>min</code> for details.</dd></dl>
  299. <h2>Example </h2>
  300. <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="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="max_8hpp.html">boost/hana/max.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-Orderable.html#ga999eee8ca8750f9b1afa0d7a1db28030">hana::max</a>(1, 4) == 4, <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-Orderable.html#ga999eee8ca8750f9b1afa0d7a1db28030">hana::max</a>(hana::int_c&lt;7&gt;, hana::int_c&lt;5&gt;) == hana::int_c&lt;7&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  301. </div>
  302. </div>
  303. <a id="ga2d54f189ea6f57fb2c0d772169440c5c"></a>
  304. <h2 class="memtitle"><span class="permalink"><a href="#ga2d54f189ea6f57fb2c0d772169440c5c">&#9670;&nbsp;</a></span>min</h2>
  305. <div class="memitem">
  306. <div class="memproto">
  307. <table class="memname">
  308. <tr>
  309. <td class="memname">constexpr auto boost::hana::min</td>
  310. </tr>
  311. </table>
  312. </div><div class="memdoc">
  313. <p><code>#include &lt;<a class="el" href="fwd_2min_8hpp.html">boost/hana/fwd/min.hpp</a>&gt;</code></p>
  314. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div><div class="line"> }</div></div><!-- fragment -->
  315. <p>Returns the smallest of its arguments according to the <code>less</code> ordering. </p>
  316. <dl class="todo"><dt><b><a class="el" href="todo.html#_todo000006">Todo:</a></b></dt><dd>We can't specify the signature right now, because the tag of the returned object depends on whether <code>x &lt; y</code> or not. If we wanted to be mathematically correct, we should probably ask that <code>if_(cond, x, y)</code> returns a common data type of <code>x</code> and <code>y</code>, and then the behavior of <code>min</code> would follow naturally. However, I'm unsure whether this is desirable because that's a big requirement.</dd></dl>
  317. <h2>Example </h2>
  318. <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="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="min_8hpp.html">boost/hana/min.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-Orderable.html#ga2d54f189ea6f57fb2c0d772169440c5c">hana::min</a>(1, 4) == 1, <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-Orderable.html#ga2d54f189ea6f57fb2c0d772169440c5c">hana::min</a>(hana::int_c&lt;7&gt;, hana::int_c&lt;5&gt;) == hana::int_c&lt;5&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  319. </div>
  320. </div>
  321. <a id="gaf7e94ba859710cd6ba6152e5dc18977d"></a>
  322. <h2 class="memtitle"><span class="permalink"><a href="#gaf7e94ba859710cd6ba6152e5dc18977d">&#9670;&nbsp;</a></span>ordering</h2>
  323. <div class="memitem">
  324. <div class="memproto">
  325. <table class="memname">
  326. <tr>
  327. <td class="memname">constexpr auto boost::hana::ordering</td>
  328. </tr>
  329. </table>
  330. </div><div class="memdoc">
  331. <p><code>#include &lt;<a class="el" href="fwd_2ordering_8hpp.html">boost/hana/fwd/ordering.hpp</a>&gt;</code></p>
  332. <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, <span class="keyword">auto</span>&amp;&amp; y) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(f(forwarded(x)), f(forwarded(y)));</div><div class="line"> };</div><div class="line"> }</div><div class="ttc" id="group__group-Orderable_html_gad510011602bdb14686f1c4ec145301c9"><div class="ttname"><a href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">boost::hana::less</a></div><div class="ttdeci">constexpr auto less</div><div class="ttdoc">Returns a Logical representing whether x is less than y.</div><div class="ttdef"><b>Definition:</b> less.hpp:37</div></div>
  333. <div class="ttc" id="group__group-functional_html_ga41ada6b336e9d5bcb101ff0c737acbd0"><div class="ttname"><a href="group__group-functional.html#ga41ada6b336e9d5bcb101ff0c737acbd0">boost::hana::capture</a></div><div class="ttdeci">constexpr auto capture</div><div class="ttdoc">Create a function capturing the given variables.</div><div class="ttdef"><b>Definition:</b> capture.hpp:45</div></div>
  334. </div><!-- fragment -->
  335. <p>Returns a function performing <code>less</code> after applying a transformation to both arguments.<code>ordering</code> creates a total order based on the result of applying a function to some objects, which is especially useful in conjunction with algorithms that accept a custom predicate that must represent a total order. </p>
  336. <p>Specifically, <code>ordering</code> is such that </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">ordering</a>(f) == <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a> ^<a class="code" href="group__group-functional.html#ga35c4fc3c5677b9f558150b90e74d3ab1">on</a>^ f</div></div><!-- fragment --><p> or, equivalently, </p><div class="fragment"><div class="line"><a class="code" href="group__group-Orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">ordering</a>(f)(x, y) == <a class="code" href="group__group-Orderable.html#gad510011602bdb14686f1c4ec145301c9">less</a>(f(x), f(y))</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>This is not a tag-dispatched method (hence it can't be customized), but just a convenience function provided with the <code>Orderable</code> concept.</dd></dl>
  337. <h2>Signature </h2>
  338. <p>Given a Logical <code>Bool</code> and an Orderable <code>B</code>, the signature is \( \mathrm{ordering} : (A \to B) \to (A \times A \to Bool) \).</p>
  339. <h2>Example </h2>
  340. <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="ordering_8hpp.html">boost/hana/ordering.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="sort_8hpp.html">boost/hana/sort.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"><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> sorted = <a class="code" href="group__group-Sequence.html#gac000a79eb7b9d44ecc8982c93daa40e5">hana::sort</a>.by(<a class="code" href="group__group-Orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">hana::ordering</a>(hana::sizeof_),</div><div class="line"> hana::tuple_t&lt;<span class="keywordtype">char</span>[3], <span class="keywordtype">char</span>[1], <span class="keywordtype">char</span>[2], <span class="keywordtype">char</span>[15]&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>(sorted == hana::tuple_t&lt;<span class="keywordtype">char</span>[1], <span class="keywordtype">char</span>[2], <span class="keywordtype">char</span>[3], <span class="keywordtype">char</span>[15]&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  341. </div>
  342. </div>
  343. </div><!-- contents -->
  344. </div><!-- doc-content -->
  345. <!--
  346. Copyright Louis Dionne 2013-2017
  347. Distributed under the Boost Software License, Version 1.0.
  348. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  349. -->
  350. <!-- boost-no-inspect -->
  351. <!-- HTML footer for doxygen 1.8.9.1-->
  352. <!-- start footer part -->
  353. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  354. <ul>
  355. </ul>
  356. </div>
  357. </body>
  358. </html>