644 lines
57 KiB
HTML
644 lines
57 KiB
HTML
<!--
|
|
Copyright Louis Dionne 2013-2017
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
-->
|
|
<!-- boost-no-inspect -->
|
|
<!-- HTML header for doxygen 1.8.9.1-->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.20"/>
|
|
<title>Boost.Hana: Orderable</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function() { init_search(); });
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
extensions: ["tex2jax.js"],
|
|
jax: ["input/TeX","output/HTML-CSS"],
|
|
});
|
|
// Copyright Louis Dionne 2013-2017
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
MathJax.Hub.Config({
|
|
"HTML-CSS": {
|
|
linebreaks: {
|
|
automatic: true,
|
|
width: "75% container"
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<!-- Additional javascript for drawing charts. -->
|
|
<script type="text/javascript" src="highcharts.js"></script>
|
|
<script type="text/javascript" src="highcharts-data.js"></script>
|
|
<script type="text/javascript" src="highcharts-exporting.js"></script>
|
|
<script type="text/javascript" src="chart.js"></script>
|
|
<script type="text/javascript" src="hana.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">Boost.Hana
|
|
 <span id="projectnumber">1.7.0</span>
|
|
</div>
|
|
<div id="projectbrief">Your standard library for metaprogramming</div>
|
|
</td>
|
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.svg"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.20 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function(){initNavTree('group__group-_orderable.html',''); initResizable(); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#var-members">Variables</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">Orderable<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
|
|
<p>The <code>Orderable</code> concept represents totally ordered data types. </p>
|
|
<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 <= b = !(b < a)</div>
|
|
<div class="line">a < b = !(b <= 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>
|
|
<h2><a class="anchor" id="autotoc_md152"></a>
|
|
Minimal complete definition</h2>
|
|
<p><code>less</code></p>
|
|
<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>
|
|
<h2><a class="anchor" id="autotoc_md153"></a>
|
|
Laws</h2>
|
|
<p>Rigorously speaking, a <a href="http://en.wikipedia.org/wiki/Total_order">total order</a> <code><=</code> on a set <code>S</code> is a binary predicate \( <= \;: 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 <= b and b <= 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 <= b and b <= c <a class="code" href="group__group-_monad.html#gaaddd3789de43cf989babb10cdc0b447a">then</a> a <= c <span class="comment">// Transitivity</span></div>
|
|
<div class="line">either a <= b or b <= 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 < b <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> !(b <= a)</div>
|
|
<div class="line">a > b <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> b < a</div>
|
|
<div class="line">a >= b <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> !(a < b)</div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md154"></a>
|
|
Refined concept</h2>
|
|
<ol type="1">
|
|
<li><code>Comparable</code> (free model)<br />
|
|
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) && <a class="code" href="group__group-_orderable.html#ga9917dd82beb67151bf5657245d37b851">less_equal</a>(y, x)</div>
|
|
</div><!-- fragment --></li>
|
|
</ol>
|
|
<h2><a class="anchor" id="autotoc_md155"></a>
|
|
Concrete models</h2>
|
|
<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>
|
|
<h2><a class="anchor" id="autotoc_md156"></a>
|
|
Free model for <tt>LessThanComparable</tt> data types</h2>
|
|
<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 < 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><</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<</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>
|
|
<h2><a class="anchor" id="autotoc_md157"></a>
|
|
Order-preserving functions</h2>
|
|
<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><a class="anchor" id="autotoc_md158"></a>
|
|
Cross-type version of the methods</h2>
|
|
<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">
|
|
<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>
|
|
<li><code>A</code>, <code>B</code> and <code>C</code> are all <code>Orderable</code> when taken individually</li>
|
|
<li>\(\mathrm{to<C>} : A \to C\) and \(\mathrm{to<C>} : B \to C\) are both order-embeddings as determined by the <code>is_embedding</code> metafunction.</li>
|
|
</ol>
|
|
<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<C>(x), to<C>(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<C>(x), to<C>(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<C>(x), to<C>(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<C>(x), to<C>(y))</div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md159"></a>
|
|
Partial application of the methods</h2>
|
|
<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>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
|
|
Variables</h2></td></tr>
|
|
<tr class="memitem:gaf9a073eafebbe514fb19dff82318f198"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#gaf9a073eafebbe514fb19dff82318f198">boost::hana::greater</a></td></tr>
|
|
<tr class="memdesc:gaf9a073eafebbe514fb19dff82318f198"><td class="mdescLeft"> </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>
|
|
<tr class="separator:gaf9a073eafebbe514fb19dff82318f198"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga6023631e7d0a01e16dc3fa4221fbd703"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">boost::hana::greater_equal</a></td></tr>
|
|
<tr class="memdesc:ga6023631e7d0a01e16dc3fa4221fbd703"><td class="mdescLeft"> </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>
|
|
<tr class="separator:ga6023631e7d0a01e16dc3fa4221fbd703"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gad510011602bdb14686f1c4ec145301c9"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#gad510011602bdb14686f1c4ec145301c9">boost::hana::less</a></td></tr>
|
|
<tr class="memdesc:gad510011602bdb14686f1c4ec145301c9"><td class="mdescLeft"> </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>
|
|
<tr class="separator:gad510011602bdb14686f1c4ec145301c9"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga9917dd82beb67151bf5657245d37b851"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#ga9917dd82beb67151bf5657245d37b851">boost::hana::less_equal</a></td></tr>
|
|
<tr class="memdesc:ga9917dd82beb67151bf5657245d37b851"><td class="mdescLeft"> </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>
|
|
<tr class="separator:ga9917dd82beb67151bf5657245d37b851"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga999eee8ca8750f9b1afa0d7a1db28030"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#ga999eee8ca8750f9b1afa0d7a1db28030">boost::hana::max</a></td></tr>
|
|
<tr class="memdesc:ga999eee8ca8750f9b1afa0d7a1db28030"><td class="mdescLeft"> </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>
|
|
<tr class="separator:ga999eee8ca8750f9b1afa0d7a1db28030"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga2d54f189ea6f57fb2c0d772169440c5c"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#ga2d54f189ea6f57fb2c0d772169440c5c">boost::hana::min</a></td></tr>
|
|
<tr class="memdesc:ga2d54f189ea6f57fb2c0d772169440c5c"><td class="mdescLeft"> </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>
|
|
<tr class="separator:ga2d54f189ea6f57fb2c0d772169440c5c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gaf7e94ba859710cd6ba6152e5dc18977d"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">boost::hana::ordering</a></td></tr>
|
|
<tr class="memdesc:gaf7e94ba859710cd6ba6152e5dc18977d"><td class="mdescLeft"> </td><td class="mdescRight">Returns a function performing <code>less</code> after applying a transformation to both arguments. <a href="group__group-_orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">More...</a><br /></td></tr>
|
|
<tr class="separator:gaf7e94ba859710cd6ba6152e5dc18977d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<h2 class="groupheader">Variable Documentation</h2>
|
|
<a id="gaf9a073eafebbe514fb19dff82318f198"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gaf9a073eafebbe514fb19dff82318f198">◆ </a></span>greater</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::greater</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2greater_8hpp.html">boost/hana/fwd/greater.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& x, <span class="keyword">auto</span>&& y) -> decltype(<span class="keyword">auto</span>) {</div>
|
|
<div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div>
|
|
<div class="line"> }</div>
|
|
</div><!-- fragment -->
|
|
<p>Returns a <code>Logical</code> representing whether <code>x</code> is greater than <code>y</code>. </p>
|
|
<h2><a class="anchor" id="autotoc_md240"></a>
|
|
Signature</h2>
|
|
<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>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<h2><a class="anchor" id="autotoc_md241"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="greater_8hpp.html">boost/hana/greater.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></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">""</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<1>, hana::int_c<3>));</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga6023631e7d0a01e16dc3fa4221fbd703"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga6023631e7d0a01e16dc3fa4221fbd703">◆ </a></span>greater_equal</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::greater_equal</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2greater__equal_8hpp.html">boost/hana/fwd/greater_equal.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& x, <span class="keyword">auto</span>&& y) -> decltype(<span class="keyword">auto</span>) {</div>
|
|
<div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div>
|
|
<div class="line"> }</div>
|
|
</div><!-- fragment -->
|
|
<p>Returns a <code>Logical</code> representing whether <code>x</code> is greater than or equal to <code>y</code>. </p>
|
|
<h2><a class="anchor" id="autotoc_md242"></a>
|
|
Signature</h2>
|
|
<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>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<h2><a class="anchor" id="autotoc_md243"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="greater__equal_8hpp.html">boost/hana/greater_equal.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></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">""</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">""</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<1>, hana::int_c<2>));</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gad510011602bdb14686f1c4ec145301c9"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gad510011602bdb14686f1c4ec145301c9">◆ </a></span>less</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::less</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2less_8hpp.html">boost/hana/fwd/less.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& x, <span class="keyword">auto</span>&& y) {</div>
|
|
<div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div>
|
|
<div class="line"> }</div>
|
|
</div><!-- fragment -->
|
|
<p>Returns a <code>Logical</code> representing whether <code>x</code> is less than <code>y</code>. </p>
|
|
<h2><a class="anchor" id="autotoc_md262"></a>
|
|
Signature</h2>
|
|
<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>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<h2><a class="anchor" id="autotoc_md263"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="all__of_8hpp.html">boost/hana/all_of.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="less_8hpp.html">boost/hana/less.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>></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">""</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<3>, hana::int_c<2>));</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<int, 1, 2, 3, 4>, <a class="code" href="group__group-_orderable.html#gad510011602bdb14686f1c4ec145301c9">hana::less</a>.than(5)), <span class="stringliteral">""</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<int, 1, 2, 3, 4>, <a class="code" href="group__group-_orderable.html#ga9917dd82beb67151bf5657245d37b851">hana::less_equal</a>.than(hana::int_c<4>)));</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga9917dd82beb67151bf5657245d37b851"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga9917dd82beb67151bf5657245d37b851">◆ </a></span>less_equal</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::less_equal</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2less__equal_8hpp.html">boost/hana/fwd/less_equal.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& x, <span class="keyword">auto</span>&& y) {</div>
|
|
<div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div>
|
|
<div class="line"> }</div>
|
|
</div><!-- fragment -->
|
|
<p>Returns a <code>Logical</code> representing whether <code>x</code> is less than or equal to <code>y</code>. </p>
|
|
<h2><a class="anchor" id="autotoc_md264"></a>
|
|
Signature</h2>
|
|
<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>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">x,y</td><td>Two objects to compare.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<h2><a class="anchor" id="autotoc_md265"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="less__equal_8hpp.html">boost/hana/less_equal.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>></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">""</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">""</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<3>, hana::int_c<2>));</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga999eee8ca8750f9b1afa0d7a1db28030"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga999eee8ca8750f9b1afa0d7a1db28030">◆ </a></span>max</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::max</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2max_8hpp.html">boost/hana/fwd/max.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& x, <span class="keyword">auto</span>&& y) -> decltype(<span class="keyword">auto</span>) {</div>
|
|
<div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div>
|
|
<div class="line"> }</div>
|
|
</div><!-- fragment -->
|
|
<p>Returns the greatest of its arguments according to the <code>less</code> ordering. </p>
|
|
<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>
|
|
<h2><a class="anchor" id="autotoc_md282"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="max_8hpp.html">boost/hana/max.hpp</a>></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">""</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<7>, hana::int_c<5>) == hana::int_c<7>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga2d54f189ea6f57fb2c0d772169440c5c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga2d54f189ea6f57fb2c0d772169440c5c">◆ </a></span>min</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::min</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2min_8hpp.html">boost/hana/fwd/min.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& x, <span class="keyword">auto</span>&& y) -> decltype(<span class="keyword">auto</span>) {</div>
|
|
<div class="line"> <span class="keywordflow">return</span> tag-dispatched;</div>
|
|
<div class="line"> }</div>
|
|
</div><!-- fragment -->
|
|
<p>Returns the smallest of its arguments according to the <code>less</code> ordering. </p>
|
|
<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 < 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>
|
|
<h2><a class="anchor" id="autotoc_md285"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="min_8hpp.html">boost/hana/min.hpp</a>></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">""</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<7>, hana::int_c<5>) == hana::int_c<5>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gaf7e94ba859710cd6ba6152e5dc18977d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gaf7e94ba859710cd6ba6152e5dc18977d">◆ </a></span>ordering</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::ordering</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p><code>#include <<a class="el" href="fwd_2ordering_8hpp.html">boost/hana/fwd/ordering.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&& 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>&& x, <span class="keyword">auto</span>&& y) -> 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><!-- fragment -->
|
|
<p>Returns a function performing <code>less</code> after applying a transformation to both arguments. </p>
|
|
<p><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>
|
|
<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>
|
|
<h2><a class="anchor" id="autotoc_md318"></a>
|
|
Signature</h2>
|
|
<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>
|
|
<h2><a class="anchor" id="autotoc_md319"></a>
|
|
Example</h2>
|
|
<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 <<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="ordering_8hpp.html">boost/hana/ordering.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="sort_8hpp.html">boost/hana/sort.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>></span></div>
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>></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 = hana::sort.by(<a class="code" href="group__group-_orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">hana::ordering</a>(hana::sizeof_),</div>
|
|
<div class="line"> hana::tuple_t<<span class="keywordtype">char</span>[3], <span class="keywordtype">char</span>[1], <span class="keywordtype">char</span>[2], <span class="keywordtype">char</span>[15]></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<<span class="keywordtype">char</span>[1], <span class="keywordtype">char</span>[2], <span class="keywordtype">char</span>[3], <span class="keywordtype">char</span>[15]>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<div class="ttc" id="aless_8hpp_html"><div class="ttname"><a href="less_8hpp.html">less.hpp</a></div><div class="ttdoc">Defines boost::hana::less.</div></div>
|
|
<div class="ttc" id="aequal_8hpp_html"><div class="ttname"><a href="equal_8hpp.html">equal.hpp</a></div><div class="ttdoc">Defines boost::hana::equal.</div></div>
|
|
<div class="ttc" id="agroup__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>
|
|
<div class="ttc" id="agroup__group-_orderable_html_ga9917dd82beb67151bf5657245d37b851"><div class="ttname"><a href="group__group-_orderable.html#ga9917dd82beb67151bf5657245d37b851">boost::hana::less_equal</a></div><div class="ttdeci">constexpr auto less_equal</div><div class="ttdoc">Returns a Logical representing whether x is less than or equal to y.</div><div class="ttdef"><b>Definition:</b> less_equal.hpp:38</div></div>
|
|
<div class="ttc" id="agroup__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>
|
|
<div class="ttc" id="agroup__group-assertions_html_ga2c5006540936d9f8880e3a39f4fcc035"><div class="ttname"><a href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTANT_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...</div><div class="ttdef"><b>Definition:</b> assert.hpp:239</div></div>
|
|
<div class="ttc" id="atuple_8hpp_html"><div class="ttname"><a href="tuple_8hpp.html">tuple.hpp</a></div><div class="ttdoc">Defines boost::hana::tuple.</div></div>
|
|
<div class="ttc" id="agroup__group-_orderable_html_gaf7e94ba859710cd6ba6152e5dc18977d"><div class="ttname"><a href="group__group-_orderable.html#gaf7e94ba859710cd6ba6152e5dc18977d">boost::hana::ordering</a></div><div class="ttdeci">constexpr auto ordering</div><div class="ttdoc">Returns a function performing less after applying a transformation to both arguments.</div><div class="ttdef"><b>Definition:</b> ordering.hpp:50</div></div>
|
|
<div class="ttc" id="aintegral__constant_8hpp_html"><div class="ttname"><a href="integral__constant_8hpp.html">integral_constant.hpp</a></div><div class="ttdoc">Defines boost::hana::integral_constant.</div></div>
|
|
<div class="ttc" id="agroup__group-_monad_html_gaaddd3789de43cf989babb10cdc0b447a"><div class="ttname"><a href="group__group-_monad.html#gaaddd3789de43cf989babb10cdc0b447a">boost::hana::then</a></div><div class="ttdeci">constexpr auto then</div><div class="ttdoc">Sequentially compose two monadic actions, discarding any value produced by the first but not its effe...</div><div class="ttdef"><b>Definition:</b> then.hpp:36</div></div>
|
|
<div class="ttc" id="amin_8hpp_html"><div class="ttname"><a href="min_8hpp.html">min.hpp</a></div><div class="ttdoc">Defines boost::hana::min.</div></div>
|
|
<div class="ttc" id="agroup__group-functional_html_ga35c4fc3c5677b9f558150b90e74d3ab1"><div class="ttname"><a href="group__group-functional.html#ga35c4fc3c5677b9f558150b90e74d3ab1">boost::hana::on</a></div><div class="ttdeci">constexpr auto on</div><div class="ttdoc">Invoke a function with the result of invoking another function on each argument.</div><div class="ttdef"><b>Definition:</b> on.hpp:54</div></div>
|
|
<div class="ttc" id="agroup__group-_orderable_html_ga2d54f189ea6f57fb2c0d772169440c5c"><div class="ttname"><a href="group__group-_orderable.html#ga2d54f189ea6f57fb2c0d772169440c5c">boost::hana::min</a></div><div class="ttdeci">constexpr auto min</div><div class="ttdoc">Returns the smallest of its arguments according to the less ordering.</div><div class="ttdef"><b>Definition:</b> min.hpp:35</div></div>
|
|
<div class="ttc" id="aall__of_8hpp_html"><div class="ttname"><a href="all__of_8hpp.html">all_of.hpp</a></div><div class="ttdoc">Defines boost::hana::all_of.</div></div>
|
|
<div class="ttc" id="agroup__group-_orderable_html_ga999eee8ca8750f9b1afa0d7a1db28030"><div class="ttname"><a href="group__group-_orderable.html#ga999eee8ca8750f9b1afa0d7a1db28030">boost::hana::max</a></div><div class="ttdeci">constexpr auto max</div><div class="ttdoc">Returns the greatest of its arguments according to the less ordering.</div><div class="ttdef"><b>Definition:</b> max.hpp:28</div></div>
|
|
<div class="ttc" id="agreater_8hpp_html"><div class="ttname"><a href="greater_8hpp.html">greater.hpp</a></div><div class="ttdoc">Defines boost::hana::greater.</div></div>
|
|
<div class="ttc" id="atype_8hpp_html"><div class="ttname"><a href="type_8hpp.html">type.hpp</a></div><div class="ttdoc">Defines boost::hana::type and related utilities.</div></div>
|
|
<div class="ttc" id="aless__equal_8hpp_html"><div class="ttname"><a href="less__equal_8hpp.html">less_equal.hpp</a></div><div class="ttdoc">Defines boost::hana::less_equal.</div></div>
|
|
<div class="ttc" id="anamespaceboost_1_1hana_html"><div class="ttname"><a href="namespaceboost_1_1hana.html">boost::hana</a></div><div class="ttdoc">Namespace containing everything in the library.</div><div class="ttdef"><b>Definition:</b> accessors.hpp:20</div></div>
|
|
<div class="ttc" id="aassert_8hpp_html"><div class="ttname"><a href="assert_8hpp.html">assert.hpp</a></div><div class="ttdoc">Defines macros to perform different kinds of assertions.</div></div>
|
|
<div class="ttc" id="aordering_8hpp_html"><div class="ttname"><a href="ordering_8hpp.html">ordering.hpp</a></div><div class="ttdoc">Defines boost::hana::ordering.</div></div>
|
|
<div class="ttc" id="amax_8hpp_html"><div class="ttname"><a href="max_8hpp.html">max.hpp</a></div><div class="ttdoc">Defines boost::hana::max.</div></div>
|
|
<div class="ttc" id="agroup__group-_orderable_html_ga6023631e7d0a01e16dc3fa4221fbd703"><div class="ttname"><a href="group__group-_orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703">boost::hana::greater_equal</a></div><div class="ttdeci">constexpr auto greater_equal</div><div class="ttdoc">Returns a Logical representing whether x is greater than or equal to y.</div><div class="ttdef"><b>Definition:</b> greater_equal.hpp:38</div></div>
|
|
<div class="ttc" id="agroup__group-_searchable_html_ga3a168950082f38afd9edf256f336c8ba"><div class="ttname"><a href="group__group-_searchable.html#ga3a168950082f38afd9edf256f336c8ba">boost::hana::all_of</a></div><div class="ttdeci">constexpr auto all_of</div><div class="ttdoc">Returns whether all the keys of the structure satisfy the predicate.</div><div class="ttdef"><b>Definition:</b> all_of.hpp:38</div></div>
|
|
<div class="ttc" id="asort_8hpp_html"><div class="ttname"><a href="sort_8hpp.html">sort.hpp</a></div><div class="ttdoc">Defines boost::hana::sort.</div></div>
|
|
<div class="ttc" id="anot_8hpp_html"><div class="ttname"><a href="not_8hpp.html">not.hpp</a></div><div class="ttdoc">Defines boost::hana::not_.</div></div>
|
|
<div class="ttc" id="agreater__equal_8hpp_html"><div class="ttname"><a href="greater__equal_8hpp.html">greater_equal.hpp</a></div><div class="ttdoc">Defines boost::hana::greater_equal.</div></div>
|
|
<div class="ttc" id="agroup__group-_orderable_html_gaf9a073eafebbe514fb19dff82318f198"><div class="ttname"><a href="group__group-_orderable.html#gaf9a073eafebbe514fb19dff82318f198">boost::hana::greater</a></div><div class="ttdeci">constexpr auto greater</div><div class="ttdoc">Returns a Logical representing whether x is greater than y.</div><div class="ttdef"><b>Definition:</b> greater.hpp:37</div></div>
|
|
<div class="ttc" id="agroup__group-_comparable_html_gacaf1ebea6b3ab96ac9dcb82f0e64e547"><div class="ttname"><a href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">boost::hana::equal</a></div><div class="ttdeci">constexpr auto equal</div><div class="ttdoc">Returns a Logical representing whether x is equal to y.</div><div class="ttdef"><b>Definition:</b> equal.hpp:64</div></div>
|
|
<!--
|
|
Copyright Louis Dionne 2013-2017
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
-->
|
|
<!-- boost-no-inspect -->
|
|
<!-- HTML footer for doxygen 1.8.9.1-->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|