boost/libs/hana/doc/html/group__group-Metafunction.html
2018-01-12 21:47:58 +01:00

281 lines
36 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.11"/>
<title>Boost.Hana: Metafunction</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>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</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">
$(document).ready(function() { init_search(); });
</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" 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
&#160;<span id="projectnumber">1.3.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.png"
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.png" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</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">
$(document).ready(function(){initNavTree('group__group-Metafunction.html','');});
</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">Metafunction<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>A <code>Metafunction</code> is a function that takes <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code>s as inputs and returns a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> as output. </p>
<p>A <code>Metafunction</code> is an object satisfying the <a href="http://en.cppreference.com/w/cpp/concept/FunctionObject">FunctionObject</a> concept, but with additional requirements. First, it must be possible to apply a <code>Metafunction</code> to arguments whose tag is <code><a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type. ">type_tag</a></code>, and the result of such an application must be an object whose tag is also <code><a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type. ">type_tag</a></code>. Note that <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> and <code><a class="el" href="structboost_1_1hana_1_1basic__type.html" title="Base class of hana::type; used for pattern-matching. ">hana::basic_type</a></code> are the only such types.</p>
<p>Secondly, a <code>Metafunction</code> must provide a nested <code>::apply</code> template which allows performing the same type-level computation as is done by the call operator. In Boost.MPL parlance, a <code>Metafunction</code> <code>F</code> is hence a <a href="http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/metafunction-class.html">MetafunctionClass</a> in addition to being a <code>FunctionObject</code>. Rigorously, the following must be satisfied by any object <code>f</code> of type <code>F</code> which is a <code>Metafunction</code>, and for arbitrary types <code>T...</code>: </p><div class="fragment"><div class="line">f(hana::type_c&lt;T&gt;...) == hana::type_c&lt;<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">F::apply</a>&lt;T...&gt;::type&gt;</div></div><!-- fragment --><p>Thirdly, to ease the inter-operation of values and types, <code>Metafunction</code>s must also allow being called with arguments that are not <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code>s. In that case, the result is equivalent to calling the metafunction on the types of the arguments. Rigorously, this means that for arbitrary objects <code>x...</code>, </p><div class="fragment"><div class="line">f(x...) == f(hana::type_c&lt;decltype(x)&gt;...)</div></div><!-- fragment --><h2>Minimal complete definition </h2>
<p>The <code>Metafunction</code> concept does not have a minimal complete definition in terms of tag-dispatched methods. Instead, the syntactic requirements documented above should be satisfied, and the <code>Metafunction</code> struct should be specialized explicitly in Hana's namespace.</p>
<h2>Concrete models </h2>
<p><code><a class="el" href="group__group-Metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a" title="Lift a MPL-style metafunction to a Metafunction.Given a MPL-style metafunction, metafunction&lt;f&gt; is a ...">hana::metafunction</a></code>, <code><a class="el" href="group__group-Metafunction.html#gacec153d7f86aa7cf1efd813b3fd212b4" title="Lift a MPL-style metafunction class to a Metafunction.Given a MPL-style metafunction class...">hana::metafunction_class</a></code>, <code><a class="el" href="group__group-Metafunction.html#ga246419f6c3263b648412f346106e6543" title="Lift a template to a Metafunction.Given a template class or template alias f, template_&lt;f&gt; is a Metaf...">hana::template_</a></code></p>
<h2>Rationale: Why aren't <code>Metafunction</code>s <code>Comparable</code>? </h2>
<p>When seeing <code><a class="el" href="group__group-Metafunction.html#ga246419f6c3263b648412f346106e6543" title="Lift a template to a Metafunction.Given a template class or template alias f, template_&lt;f&gt; is a Metaf...">hana::template_</a></code>, a question that naturally arises is whether <code>Metafunction</code>s should be made <code>Comparable</code>. Indeed, it would seem to make sense to compare two templates <code>F</code> and <code>G</code> with <code>template_&lt;F&gt; == template_&lt;G&gt;</code>. However, in the case where <code>F</code> and/or <code>G</code> are alias templates, it makes sense to talk about two types of comparisons. The first one is <em>shallow</em> comparison, and it determines that two alias templates are equal if they are the same alias template. The second one is <em>deep</em> comparison, and it determines that two template aliases are equal if they alias the same type for any template argument. For example, given <code>F</code> and <code>G</code> defined as </p><div class="fragment"><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><span class="keyword">using</span> F = void;</div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><span class="keyword">using</span> G = void;</div></div><!-- fragment --><p>shallow comparison would determine that <code>F</code> and <code>G</code> are different because they are two different template aliases, while deep comparison would determine that <code>F</code> and <code>G</code> are equal because they always expand to the same type, <code>void</code>. Unfortunately, deep comparison is impossible to implement because one would have to check <code>F</code> and <code>G</code> on all possible types. On the other hand, shallow comparison is not satisfactory because <code>Metafunction</code>s are nothing but functions on <code>type</code>s, and the equality of two functions is normally defined with deep comparison. Hence, we adopt a conservative stance and avoid providing comparison for <code>Metafunction</code>s.</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:ga246419f6c3263b648412f346106e6543"><td class="memTemplParams" colspan="2">template&lt;template&lt; typename... &gt; class F&gt; </td></tr>
<tr class="memitem:ga246419f6c3263b648412f346106e6543"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-Metafunction.html#ga246419f6c3263b648412f346106e6543">boost::hana::template_</a></td></tr>
<tr class="memdesc:ga246419f6c3263b648412f346106e6543"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a template to a Metafunction.Given a template class or template alias <code>f</code>, <code>template_&lt;f&gt;</code> is a <code>Metafunction</code> satisfying. <a href="group__group-Metafunction.html#ga246419f6c3263b648412f346106e6543">More...</a><br /></td></tr>
<tr class="separator:ga246419f6c3263b648412f346106e6543"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memTemplParams" colspan="2">template&lt;template&lt; typename... &gt; class F&gt; </td></tr>
<tr class="memitem:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-Metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">boost::hana::metafunction</a></td></tr>
<tr class="memdesc:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a MPL-style metafunction to a Metafunction.Given a MPL-style metafunction, <code>metafunction&lt;f&gt;</code> is a <code>Metafunction</code> satisfying. <a href="group__group-Metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">More...</a><br /></td></tr>
<tr class="separator:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memTemplParams" colspan="2">template&lt;typename F &gt; </td></tr>
<tr class="memitem:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-Metafunction.html#gacec153d7f86aa7cf1efd813b3fd212b4">boost::hana::metafunction_class</a></td></tr>
<tr class="memdesc:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a MPL-style metafunction class to a Metafunction.Given a MPL-style metafunction class, <code>metafunction_class&lt;f&gt;</code> is a <code>Metafunction</code> satisfying. <a href="group__group-Metafunction.html#gacec153d7f86aa7cf1efd813b3fd212b4">More...</a><br /></td></tr>
<tr class="separator:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf7045fe6a627f88f5f646dad22d37aae"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">boost::hana::integral</a></td></tr>
<tr class="memdesc:gaf7045fe6a627f88f5f646dad22d37aae"><td class="mdescLeft">&#160;</td><td class="mdescRight">Turn a <code>Metafunction</code> into a function taking <code>type</code>s and returning a default-constructed object.Given a <code>Metafunction</code> <code>f</code>, <code>integral</code> returns a new <code>Metafunction</code> that default-constructs an object of the type returned by <code>f</code>. More specifically, the following holds: <a href="group__group-Metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">More...</a><br /></td></tr>
<tr class="separator:gaf7045fe6a627f88f5f646dad22d37aae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6d4093318f46472e62f9539a4dc998a9"><td class="memTemplParams" colspan="2">template&lt;template&lt; typename... &gt; class F&gt; </td></tr>
<tr class="memitem:ga6d4093318f46472e62f9539a4dc998a9"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-Metafunction.html#ga6d4093318f46472e62f9539a4dc998a9">boost::hana::trait</a> = hana::integral(hana::metafunction&lt;F&gt;)</td></tr>
<tr class="memdesc:ga6d4093318f46472e62f9539a4dc998a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Alias to <code>integral(metafunction&lt;F&gt;)</code>, provided for convenience. <a href="group__group-Metafunction.html#ga6d4093318f46472e62f9539a4dc998a9">More...</a><br /></td></tr>
<tr class="separator:ga6d4093318f46472e62f9539a4dc998a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Variable Documentation</h2>
<a class="anchor" id="ga246419f6c3263b648412f346106e6543"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;template&lt; typename... &gt; class F&gt; </div>
<table class="memname">
<tr>
<td class="memname">constexpr auto boost::hana::template_</td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type&lt;T&gt;...) {</div><div class="line"> <span class="keywordflow">return</span> hana::type_c&lt;F&lt;T...&gt;&gt;;</div><div class="line"> }</div></div><!-- fragment -->
<p>Lift a template to a Metafunction.Given a template class or template alias <code>f</code>, <code>template_&lt;f&gt;</code> is a <code>Metafunction</code> satisfying. </p>
<div class="fragment"><div class="line">template_&lt;f&gt;(type_c&lt;x&gt;...) == type_c&lt;f&lt;x...&gt;&gt;</div><div class="line">decltype(template_&lt;f&gt;)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type == f&lt;x...&gt;</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><code>template_</code> can't be SFINAE-friendly right now because of <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1430">Core issue 1430</a>.</dd></dl>
<h2>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 &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="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt; <span class="keyword">struct </span>f;</div><div class="line"><span class="keyword">struct </span>x;</div><div class="line"><span class="keyword">struct </span>y;</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_&lt;f&gt;() == hana::type_c&lt;f&lt;&gt;&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_&lt;f&gt;(hana::type_c&lt;x&gt;) == hana::type_c&lt;f&lt;x&gt;&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_&lt;f&gt;(hana::type_c&lt;x&gt;, hana::type_c&lt;y&gt;) == hana::type_c&lt;f&lt;x, y&gt;&gt;);</div><div class="line"></div><div class="line">static_assert(std::is_same&lt;</div><div class="line"> decltype(hana::template_&lt;f&gt;)::apply&lt;x, y&gt;::type,</div><div class="line"> f&lt;x, y&gt;</div><div class="line">&gt;::<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gaaa4f85cb8cbce21f5c04ef40ca35cc6a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;template&lt; typename... &gt; class F&gt; </div>
<table class="memname">
<tr>
<td class="memname">constexpr auto boost::hana::metafunction</td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type&lt;T&gt;...) {</div><div class="line"> <span class="keywordflow">return</span> hana::type_c&lt;<span class="keyword">typename</span> F&lt;T...&gt;::type&gt;;</div><div class="line"> }</div></div><!-- fragment -->
<p>Lift a MPL-style metafunction to a Metafunction.Given a MPL-style metafunction, <code>metafunction&lt;f&gt;</code> is a <code>Metafunction</code> satisfying. </p>
<div class="fragment"><div class="line">metafunction&lt;f&gt;(type_c&lt;x&gt;...) == type_c&lt;f&lt;x...&gt;::type&gt;</div><div class="line">decltype(metafunction&lt;f&gt;)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type == f&lt;x...&gt;::type</div></div><!-- fragment --><h2>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 &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="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt; <span class="keyword">struct </span>f { <span class="keyword">struct </span>type; };</div><div class="line"><span class="keyword">struct </span>x;</div><div class="line"><span class="keyword">struct </span>y;</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction&lt;f&gt;() == hana::type_c&lt;f&lt;&gt;::type&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction&lt;f&gt;(hana::type_c&lt;x&gt;) == hana::type_c&lt;f&lt;x&gt;::type&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction&lt;f&gt;(hana::type_c&lt;x&gt;, hana::type_c&lt;y&gt;) == hana::type_c&lt;f&lt;x, y&gt;::type&gt;);</div><div class="line"></div><div class="line">static_assert(std::is_same&lt;</div><div class="line"> decltype(hana::metafunction&lt;f&gt;)::apply&lt;x, y&gt;::type,</div><div class="line"> f&lt;x, y&gt;::type</div><div class="line">&gt;::<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gacec153d7f86aa7cf1efd813b3fd212b4"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename F &gt; </div>
<table class="memname">
<tr>
<td class="memname">constexpr auto boost::hana::metafunction_class</td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type&lt;T&gt;...) {</div><div class="line"> <span class="keywordflow">return</span> hana::type_c&lt;<span class="keyword">typename</span> F::template <a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;T...&gt;::type&gt;;</div><div class="line"> }</div><div class="ttc" id="group__group-functional_html_ga30027c383676084be151ef3c6cf2829f"><div class="ttname"><a href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">boost::hana::apply</a></div><div class="ttdeci">constexpr auto apply</div><div class="ttdoc">Invokes a Callable with the given arguments. </div><div class="ttdef"><b>Definition:</b> apply.hpp:40</div></div>
</div><!-- fragment -->
<p>Lift a MPL-style metafunction class to a Metafunction.Given a MPL-style metafunction class, <code>metafunction_class&lt;f&gt;</code> is a <code>Metafunction</code> satisfying. </p>
<div class="fragment"><div class="line">metafunction_class&lt;f&gt;(type_c&lt;x&gt;...) == type_c&lt;<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">f::apply</a>&lt;x...&gt;::type&gt;</div><div class="line">decltype(metafunction_class&lt;f&gt;)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type == f::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type</div></div><!-- fragment --><h2>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 &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="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>f { <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt; <span class="keyword">struct </span><a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a> { <span class="keyword">struct </span>type; }; };</div><div class="line"><span class="keyword">struct </span>x;</div><div class="line"><span class="keyword">struct </span>y;</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class&lt;f&gt;() == hana::type_c&lt;f::apply&lt;&gt;::type&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class&lt;f&gt;(hana::type_c&lt;x&gt;) == hana::type_c&lt;f::apply&lt;x&gt;::type&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class&lt;f&gt;(hana::type_c&lt;x&gt;, hana::type_c&lt;y&gt;) == hana::type_c&lt;f::apply&lt;x, y&gt;::type&gt;);</div><div class="line"></div><div class="line">static_assert(std::is_same&lt;</div><div class="line"> decltype(hana::metafunction_class&lt;f&gt;)::apply&lt;x, y&gt;::type,</div><div class="line"> f::apply&lt;x, y&gt;::type</div><div class="line">&gt;::<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gaf7045fe6a627f88f5f646dad22d37aae"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">constexpr auto boost::hana::integral</td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</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> [](basic_type&lt;T&gt;...) {</div><div class="line"> <span class="keywordflow">return</span> decltype(f)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;T...&gt;::type{};</div><div class="line"> };</div><div class="line"> }</div><div class="ttc" id="group__group-functional_html_ga30027c383676084be151ef3c6cf2829f"><div class="ttname"><a href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">boost::hana::apply</a></div><div class="ttdeci">constexpr auto apply</div><div class="ttdoc">Invokes a Callable with the given arguments. </div><div class="ttdef"><b>Definition:</b> apply.hpp:40</div></div>
</div><!-- fragment -->
<p>Turn a <code>Metafunction</code> into a function taking <code>type</code>s and returning a default-constructed object.Given a <code>Metafunction</code> <code>f</code>, <code>integral</code> returns a new <code>Metafunction</code> that default-constructs an object of the type returned by <code>f</code>. More specifically, the following holds: </p>
<div class="fragment"><div class="line"><a class="code" href="group__group-Metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">integral</a>(f)(t...) == decltype(f(t...))::type{}</div></div><!-- fragment --><p>The principal use case for <code>integral</code> is to transform <code>Metafunction</code>s returning a type that inherits from a meaningful base like <code><a class="el" href="structstd_1_1integral__constant.html" title="Adapter for std::integral_constants. ">std::integral_constant</a></code> into functions returning e.g. a <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>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>This is not a <code>Metafunction</code> because it does not return a <code>type</code>. As such, it would not make sense to make <code>decltype(integral(f))</code> a MPL metafunction class like the usual <code>Metafunction</code>s are.</li>
<li>When using <code>integral</code> with metafunctions returning <code><a class="el" href="structstd_1_1integral__constant.html" title="Adapter for std::integral_constants. ">std::integral_constant</a></code>s, don't forget to include the <a class="el" href="ext_2std_2integral__constant_8hpp.html" title="Adapts std::integral_constant for use with Hana. ">boost/hana/ext/std/integral_constant.hpp</a> header to ensure Hana can interoperate with the result.</li>
</ul>
</dd></dl>
<h2>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 &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="ext_2std_2integral__constant_8hpp.html">boost/hana/ext/std/integral_constant.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="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><span class="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> is_void = <a class="code" href="group__group-Metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">hana::integral</a>(hana::metafunction&lt;std::is_void&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(is_void(hana::type_c&lt;void&gt;));</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Logical.html#ga4a7c9d7037601d5e553fd20777958980">hana::not_</a>(is_void(hana::type_c&lt;int&gt;)));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ga6d4093318f46472e62f9539a4dc998a9"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;template&lt; typename... &gt; class F&gt; </div>
<table class="memname">
<tr>
<td class="memname">constexpr auto boost::hana::trait = hana::integral(hana::metafunction&lt;F&gt;)</td>
</tr>
</table>
</div><div class="memdoc">
<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<p>Alias to <code>integral(metafunction&lt;F&gt;)</code>, provided for convenience. </p>
<h2>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 &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="ext_2std_2integral__constant_8hpp.html">boost/hana/ext/std/integral_constant.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="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><span class="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#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::trait&lt;std::is_integral&gt;(hana::type_c&lt;int&gt;));</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Logical.html#ga4a7c9d7037601d5e553fd20777958980">hana::not_</a>(hana::trait&lt;std::is_integral&gt;(hana::type_c&lt;float&gt;)));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!--
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>