123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <!--
- 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.15"/>
- <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">
- /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
- $(document).ready(initResizable);
- /* @license-end */</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.6.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.15 -->
- <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-Metafunction.html','');});
- /* @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">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/named_req/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<T>...) == hana::type_c<<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">F::apply</a><T...>::type></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<decltype(x)>...)</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<f> 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_<f> 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_<f> 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_<F> == template_<G></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> <<span class="keyword">typename</span> T></div><div class="line"><span class="keyword">using</span> F = void;</div><div class="line"></div><div class="line"><span class="keyword">template</span> <<span class="keyword">typename</span> T></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<template< typename ... > class F> </td></tr>
- <tr class="memitem:ga246419f6c3263b648412f346106e6543"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto </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"> </td><td class="mdescRight">Lift a template to a Metafunction.Given a template class or template alias <code>f</code>, <code>template_<f></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"> </td></tr>
- <tr class="memitem:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memTemplParams" colspan="2">template<template< typename ... > class F> </td></tr>
- <tr class="memitem:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto </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"> </td><td class="mdescRight">Lift a MPL-style metafunction to a Metafunction.Given a MPL-style metafunction, <code>metafunction<f></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"> </td></tr>
- <tr class="memitem:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memTemplParams" colspan="2">template<typename F > </td></tr>
- <tr class="memitem:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto </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"> </td><td class="mdescRight">Lift a MPL-style metafunction class to a Metafunction.Given a MPL-style metafunction class, <code>metafunction_class<f></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"> </td></tr>
- <tr class="memitem:gaf7045fe6a627f88f5f646dad22d37aae"><td class="memItemLeft" align="right" valign="top">constexpr auto </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"> </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"> </td></tr>
- <tr class="memitem:ga6d4093318f46472e62f9539a4dc998a9"><td class="memTemplParams" colspan="2">template<template< typename ... > class F> </td></tr>
- <tr class="memitem:ga6d4093318f46472e62f9539a4dc998a9"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-Metafunction.html#ga6d4093318f46472e62f9539a4dc998a9">boost::hana::trait</a> = <a class="el" href="group__group-Metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">hana::integral</a>(<a class="el" href="group__group-Metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">hana::metafunction</a><F>)</td></tr>
- <tr class="memdesc:ga6d4093318f46472e62f9539a4dc998a9"><td class="mdescLeft"> </td><td class="mdescRight">Alias to <code>integral(metafunction<F>)</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"> </td></tr>
- </table>
- <h2 class="groupheader">Variable Documentation</h2>
- <a id="ga246419f6c3263b648412f346106e6543"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga246419f6c3263b648412f346106e6543">◆ </a></span>template_</h2>
- <div class="memitem">
- <div class="memproto">
- <div class="memtemplate">
- template<template< typename ... > class F> </div>
- <table class="memname">
- <tr>
- <td class="memname">constexpr auto boost::hana::template_</td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p><code>#include <<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>></code></p>
- <b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type<T>...) {</div><div class="line"> <span class="keywordflow">return</span> hana::type_c<F<T...>>;</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_<f></code> is a <code>Metafunction</code> satisfying. </p>
- <div class="fragment"><div class="line">template_<f>(type_c<x>...) == type_c<f<x...>></div><div class="line">decltype(template_<f>)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a><x...>::type == f<x...></div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In a SFINAE context, the expression <code>template_<f>(type_c<x>...)</code> is valid whenever the expression <code>f<x...></code> is valid.</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 <<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="type_8hpp.html">boost/hana/type.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <type_traits></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> <<span class="keyword">typename</span> ...> <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#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_<f>() == hana::type_c<f<>>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_<f>(hana::type_c<x>) == hana::type_c<f<x>>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_<f>(hana::type_c<x>, hana::type_c<y>) == hana::type_c<f<x, y>>);</div><div class="line"></div><div class="line">static_assert(std::is_same<</div><div class="line"> decltype(hana::template_<f>)::apply<x, y>::type,</div><div class="line"> f<x, y></div><div class="line">>::<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <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="gaaa4f85cb8cbce21f5c04ef40ca35cc6a"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">◆ </a></span>metafunction</h2>
- <div class="memitem">
- <div class="memproto">
- <div class="memtemplate">
- template<template< typename ... > class F> </div>
- <table class="memname">
- <tr>
- <td class="memname">constexpr auto boost::hana::metafunction</td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p><code>#include <<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>></code></p>
- <b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type<T>...) {</div><div class="line"> <span class="keywordflow">return</span> hana::type_c<<span class="keyword">typename</span> F<T...>::type>;</div><div class="line"> }</div></div><!-- fragment -->
- <p>Lift a MPL-style metafunction to a Metafunction.Given a MPL-style metafunction, <code>metafunction<f></code> is a <code>Metafunction</code> satisfying. </p>
- <div class="fragment"><div class="line">metafunction<f>(type_c<x>...) == type_c<f<x...>::type></div><div class="line">decltype(metafunction<f>)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a><x...>::type == f<x...>::type</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In a SFINAE context, the expression <code>metafunction<f>(type_c<x>...)</code> is valid whenever the expression <code>f<x...>::type</code> is valid.</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 <<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="type_8hpp.html">boost/hana/type.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <type_traits></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> <<span class="keyword">typename</span> ...> <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#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction<f>() == hana::type_c<f<>::type>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction<f>(hana::type_c<x>) == hana::type_c<f<x>::type>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction<f>(hana::type_c<x>, hana::type_c<y>) == hana::type_c<f<x, y>::type>);</div><div class="line"></div><div class="line">static_assert(std::is_same<</div><div class="line"> decltype(hana::metafunction<f>)::apply<x, y>::type,</div><div class="line"> f<x, y>::type</div><div class="line">>::<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <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="gacec153d7f86aa7cf1efd813b3fd212b4"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gacec153d7f86aa7cf1efd813b3fd212b4">◆ </a></span>metafunction_class</h2>
- <div class="memitem">
- <div class="memproto">
- <div class="memtemplate">
- template<typename F > </div>
- <table class="memname">
- <tr>
- <td class="memname">constexpr auto boost::hana::metafunction_class</td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p><code>#include <<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>></code></p>
- <b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type<T>...) {</div><div class="line"> <span class="keywordflow">return</span> hana::type_c<<span class="keyword">typename</span> F::template <a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a><T...>::type>;</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<f></code> is a <code>Metafunction</code> satisfying. </p>
- <div class="fragment"><div class="line">metafunction_class<f>(type_c<x>...) == type_c<<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">f::apply</a><x...>::type></div><div class="line">decltype(metafunction_class<f>)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a><x...>::type == f::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a><x...>::type</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In a SFINAE context, the expression <code>metafunction_class<f>(type_c<x>...)</code> is valid whenever the expression <code>f::apply<x...>::type</code> is valid.</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 <<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="type_8hpp.html">boost/hana/type.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <type_traits></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> <<span class="keyword">typename</span> ...> <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#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class<f>() == hana::type_c<f::apply<>::type>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class<f>(hana::type_c<x>) == hana::type_c<f::apply<x>::type>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class<f>(hana::type_c<x>, hana::type_c<y>) == hana::type_c<f::apply<x, y>::type>);</div><div class="line"></div><div class="line">static_assert(std::is_same<</div><div class="line"> decltype(hana::metafunction_class<f>)::apply<x, y>::type,</div><div class="line"> f::apply<x, y>::type</div><div class="line">>::<a class="code" href="group__group-Constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <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="gaf7045fe6a627f88f5f646dad22d37aae"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gaf7045fe6a627f88f5f646dad22d37aae">◆ </a></span>integral</h2>
- <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 <<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.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> [](basic_type<T>...) {</div><div class="line"> <span class="keywordflow">return</span> decltype(f)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a><T...>::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>
- <li>In a SFINAE context, the expression <code>integral(f)(t...)</code> is valid whenever the expression <code>decltype(f(t...))::type</code> is valid.</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 <<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="ext_2std_2integral__constant_8hpp.html">boost/hana/ext/std/integral_constant.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="type_8hpp.html">boost/hana/type.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <type_traits></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<std::is_void>);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(is_void(hana::type_c<void>));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Logical.html#ga4a7c9d7037601d5e553fd20777958980">hana::not_</a>(is_void(hana::type_c<int>)));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
- </div>
- </div>
- <a id="ga6d4093318f46472e62f9539a4dc998a9"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga6d4093318f46472e62f9539a4dc998a9">◆ </a></span>trait</h2>
- <div class="memitem">
- <div class="memproto">
- <div class="memtemplate">
- template<template< typename ... > class F> </div>
- <table class="memname">
- <tr>
- <td class="memname">constexpr auto boost::hana::trait = <a class="el" href="group__group-Metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">hana::integral</a>(<a class="el" href="group__group-Metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">hana::metafunction</a><F>)</td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p><code>#include <<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>></code></p>
- <p>Alias to <code>integral(metafunction<F>)</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 <<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="ext_2std_2integral__constant_8hpp.html">boost/hana/ext/std/integral_constant.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="type_8hpp.html">boost/hana/type.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <type_traits></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>(hana::trait<std::is_integral>(hana::type_c<int>));</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Logical.html#ga4a7c9d7037601d5e553fd20777958980">hana::not_</a>(hana::trait<std::is_integral>(hana::type_c<float>)));</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>
|