378 lines
28 KiB
HTML
378 lines
28 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: Ring</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-_ring.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">Ring<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>Ring</code> concept represents <code>Group</code>s that also form a <code>Monoid</code> under a second binary operation that distributes over the first. </p>
|
|
<p>A <a href="http://en.wikipedia.org/wiki/Ring_(mathematics)">Ring</a> is an algebraic structure built on top of a <code>Group</code> which requires a monoidal structure with respect to a second binary operation. This second binary operation must distribute over the first one. Specifically, a <code>Ring</code> is a triple <code>(S, +, *)</code> such that <code>(S, +)</code> is a <code>Group</code>, <code>(S, *)</code> is a <code>Monoid</code> and <code>*</code> distributes over <code>+</code>, i.e. </p><div class="fragment"><div class="line">x * (y + z) == (x * y) + (x * z)</div>
|
|
</div><!-- fragment --><p>The second binary operation is often written <code>*</code> with its identity written <code>1</code>, in reference to the <code>Ring</code> of integers under multiplication. The method names used here refer to this exact ring.</p>
|
|
<h2><a class="anchor" id="autotoc_md164"></a>
|
|
Minimal complete definintion</h2>
|
|
<p><code>one</code> and <code>mult</code> satisfying the laws</p>
|
|
<h2><a class="anchor" id="autotoc_md165"></a>
|
|
Laws</h2>
|
|
<p>For all objects <code>x</code>, <code>y</code>, <code>z</code> of a <code>Ring</code> <code>R</code>, the following laws must be satisfied: </p><div class="fragment"><div class="line"><a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, <a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(y, z)) == <a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(<a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, y), z) <span class="comment">// associativity</span></div>
|
|
<div class="line"><a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, one<R>()) == x <span class="comment">// right identity</span></div>
|
|
<div class="line"><a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(one<R>(), x) == x <span class="comment">// left identity</span></div>
|
|
<div class="line"><a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, <a class="code" href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(y, z)) == <a class="code" href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(<a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, y), <a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, z)) <span class="comment">// distributivity</span></div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md166"></a>
|
|
Refined concepts</h2>
|
|
<p><code>Monoid</code>, <code>Group</code></p>
|
|
<h2><a class="anchor" id="autotoc_md167"></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></p>
|
|
<h2><a class="anchor" id="autotoc_md168"></a>
|
|
Free model for non-boolean arithmetic data types</h2>
|
|
<p>A data type <code>T</code> is arithmetic if <code>std::is_arithmetic<T>::value</code> is true. For a non-boolean arithmetic data type <code>T</code>, a model of <code>Ring</code> is automatically defined by using the provided <code>Group</code> model and setting </p><div class="fragment"><div class="line"><a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, y) = (x * y)</div>
|
|
<div class="line">one<T>() = <span class="keyword">static_cast<</span>T<span class="keyword">></span>(1)</div>
|
|
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>The rationale for not providing a Ring model for <code>bool</code> is the same as for not providing Monoid and Group models.</dd></dl>
|
|
<h2><a class="anchor" id="autotoc_md169"></a>
|
|
Structure-preserving functions</h2>
|
|
<p>Let <code>A</code> and <code>B</code> be two <code>Ring</code>s. A function <code>f : A -> B</code> is said to be a <a href="http://en.wikipedia.org/wiki/Ring_homomorphism">Ring morphism</a> if it preserves the ring structure between <code>A</code> and <code>B</code>. Rigorously, for all objects <code>x, y</code> of data type <code>A</code>, </p><div class="fragment"><div class="line">f(<a class="code" href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(x, y)) == <a class="code" href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(f(x), f(y))</div>
|
|
<div class="line">f(<a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, y)) == <a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(f(x), f(y))</div>
|
|
<div class="line">f(one<A>()) == one<B>()</div>
|
|
</div><!-- fragment --><p> Because of the <code>Ring</code> structure, it is easy to prove that the following will then also be satisfied: </p><div class="fragment"><div class="line">f(zero<A>()) == zero<B>()</div>
|
|
<div class="line">f(<a class="code" href="group__group-_group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(x)) == <a class="code" href="group__group-_group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(f(x))</div>
|
|
</div><!-- fragment --><p> which is to say that <code>f</code> will then also be a <code>Group</code> morphism. Functions with these properties interact nicely with <code>Ring</code>s, which is why they are given such a special treatment. </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:ga052d31c269a6a438cc8004c9ad1efdfa"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">boost::hana::mult</a></td></tr>
|
|
<tr class="memdesc:ga052d31c269a6a438cc8004c9ad1efdfa"><td class="mdescLeft"> </td><td class="mdescRight">Associative operation of a <code>Ring</code>. <a href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">More...</a><br /></td></tr>
|
|
<tr class="separator:ga052d31c269a6a438cc8004c9ad1efdfa"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gadea531feb3b0a1c5c3d777f7ab45e932"><td class="memTemplParams" colspan="2">template<typename R > </td></tr>
|
|
<tr class="memitem:gadea531feb3b0a1c5c3d777f7ab45e932"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_ring.html#gadea531feb3b0a1c5c3d777f7ab45e932">boost::hana::one</a></td></tr>
|
|
<tr class="memdesc:gadea531feb3b0a1c5c3d777f7ab45e932"><td class="mdescLeft"> </td><td class="mdescRight">Identity of the <code>Ring</code> multiplication. <a href="group__group-_ring.html#gadea531feb3b0a1c5c3d777f7ab45e932">More...</a><br /></td></tr>
|
|
<tr class="separator:gadea531feb3b0a1c5c3d777f7ab45e932"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga0ee3cff9ec646bcc7217f00ee6099b72"><td class="memItemLeft" align="right" valign="top">constexpr auto </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_ring.html#ga0ee3cff9ec646bcc7217f00ee6099b72">boost::hana::power</a></td></tr>
|
|
<tr class="memdesc:ga0ee3cff9ec646bcc7217f00ee6099b72"><td class="mdescLeft"> </td><td class="mdescRight">Elevate a ring element to its <code>n</code>th power. <a href="group__group-_ring.html#ga0ee3cff9ec646bcc7217f00ee6099b72">More...</a><br /></td></tr>
|
|
<tr class="separator:ga0ee3cff9ec646bcc7217f00ee6099b72"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<h2 class="groupheader">Variable Documentation</h2>
|
|
<a id="ga052d31c269a6a438cc8004c9ad1efdfa"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga052d31c269a6a438cc8004c9ad1efdfa">◆ </a></span>mult</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::mult</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_2mult_8hpp.html">boost/hana/fwd/mult.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>Associative operation of a <code>Ring</code>. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">x,y</td><td>Two <code>Ring</code> elements to combine with the <code>Ring</code> binary operation.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<h2><a class="anchor" id="autotoc_md294"></a>
|
|
Cross-type version of the method</h2>
|
|
<p>The <code>mult</code> method is "overloaded" to handle distinct data types with certain properties. Specifically, <code>mult</code> is 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>Ring</code>s when taken individually</li>
|
|
<li><code>to<C> : A -> B</code> and <code>to<C> : B -> C</code> are <code>Ring</code>-embeddings, as determined by the <code>is_embedding</code> metafunction.</li>
|
|
</ol>
|
|
<p>The definition of <code>mult</code> for data types satisfying the above properties is obtained by setting </p><div class="fragment"><div class="line"><a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(x, y) = <a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">mult</a>(to<C>(x), to<C>(y))</div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md295"></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="mult_8hpp.html">boost/hana/mult.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"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">hana::mult</a>(hana::int_c<3>, hana::int_c<5>) == hana::int_c<15>);</div>
|
|
<div class="line">static_assert(<a class="code" href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">hana::mult</a>(4, 2) == 8, <span class="stringliteral">""</span>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gadea531feb3b0a1c5c3d777f7ab45e932"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gadea531feb3b0a1c5c3d777f7ab45e932">◆ </a></span>one</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename R > </div>
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">constexpr auto boost::hana::one</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_2one_8hpp.html">boost/hana/fwd/one.hpp</a>></code></p>
|
|
<b>Initial value:</b><div class="fragment"><div class="line">= []() -> 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>Identity of the <code>Ring</code> multiplication. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">R</td><td>The tag (must be a model of <code>Ring</code>) of the returned identity.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<h2><a class="anchor" id="autotoc_md302"></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="one_8hpp.html">boost/hana/one.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"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_ring.html#gadea531feb3b0a1c5c3d777f7ab45e932">hana::one</a><hana::integral_constant_tag<int>>() == hana::int_c<1>);</div>
|
|
<div class="line">static_assert(hana::one<long>() == 1l, <span class="stringliteral">""</span>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">int</span> main() { }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga0ee3cff9ec646bcc7217f00ee6099b72"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga0ee3cff9ec646bcc7217f00ee6099b72">◆ </a></span>power</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::power</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_2power_8hpp.html">boost/hana/fwd/power.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> <span class="keyword">const</span>& n) -> 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>Elevate a ring element to its <code>n</code>th power. </p>
|
|
<p>Specifically, <code>power(x, n)</code>, is equivalent to multiplying <code>x</code> with itself <code>n</code> times using the Ring's multiplication. If the power is equal to <code>zero</code>, the Ring's identity (<code>one</code>) is returned.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">x</td><td>A <code>Ring</code> element that is elevated to its <code>n</code>th power.</td></tr>
|
|
<tr><td class="paramname">n</td><td>A non-negative <code><a class="el" href="structboost_1_1hana_1_1_integral_constant.html" title="The IntegralConstant concept represents compile-time integral values.">IntegralConstant</a></code> representing the power to which <code>x</code> is elevated.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section note"><dt>Note</dt><dd>Only the tag of <code>x</code> is used for tag-dispatching.</dd></dl>
|
|
<h2><a class="anchor" id="autotoc_md327"></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="power_8hpp.html">boost/hana/power.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"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_ring.html#ga0ee3cff9ec646bcc7217f00ee6099b72">hana::power</a>(hana::int_c<3>, hana::int_c<2>) == hana::int_c<3 * 3>);</div>
|
|
<div class="line">static_assert(<a class="code" href="group__group-_ring.html#ga0ee3cff9ec646bcc7217f00ee6099b72">hana::power</a>(2, hana::int_c<4>) == 16, <span class="stringliteral">""</span>);</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="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-_ring_html_gadea531feb3b0a1c5c3d777f7ab45e932"><div class="ttname"><a href="group__group-_ring.html#gadea531feb3b0a1c5c3d777f7ab45e932">boost::hana::one</a></div><div class="ttdeci">constexpr auto one</div><div class="ttdoc">Identity of the Ring multiplication.</div><div class="ttdef"><b>Definition:</b> one.hpp:30</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="agroup__group-_group_html_ga02e81002f40ba52eac4cf1974c7e0cdb"><div class="ttname"><a href="group__group-_group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">boost::hana::negate</a></div><div class="ttdeci">constexpr auto negate</div><div class="ttdoc">Return the inverse of an element of a group.</div><div class="ttdef"><b>Definition:</b> negate.hpp:26</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="aone_8hpp_html"><div class="ttname"><a href="one_8hpp.html">one.hpp</a></div><div class="ttdoc">Defines boost::hana::one.</div></div>
|
|
<div class="ttc" id="apower_8hpp_html"><div class="ttname"><a href="power_8hpp.html">power.hpp</a></div><div class="ttdoc">Defines boost::hana::power.</div></div>
|
|
<div class="ttc" id="agroup__group-_monoid_html_gaeb5d4a1e967e319712f9e4791948896c"><div class="ttname"><a href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">boost::hana::plus</a></div><div class="ttdeci">constexpr auto plus</div><div class="ttdoc">Associative binary operation on a Monoid.</div><div class="ttdef"><b>Definition:</b> plus.hpp:47</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="agroup__group-_ring_html_ga052d31c269a6a438cc8004c9ad1efdfa"><div class="ttname"><a href="group__group-_ring.html#ga052d31c269a6a438cc8004c9ad1efdfa">boost::hana::mult</a></div><div class="ttdeci">constexpr auto mult</div><div class="ttdoc">Associative operation of a Ring.</div><div class="ttdef"><b>Definition:</b> mult.hpp:47</div></div>
|
|
<div class="ttc" id="agroup__group-_ring_html_ga0ee3cff9ec646bcc7217f00ee6099b72"><div class="ttname"><a href="group__group-_ring.html#ga0ee3cff9ec646bcc7217f00ee6099b72">boost::hana::power</a></div><div class="ttdeci">constexpr auto power</div><div class="ttdoc">Elevate a ring element to its nth power.</div><div class="ttdef"><b>Definition:</b> power.hpp:40</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="amult_8hpp_html"><div class="ttname"><a href="mult_8hpp.html">mult.hpp</a></div><div class="ttdoc">Defines boost::hana::mult.</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>
|