structboost_1_1hana_1_1type.html 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <!--
  2. Copyright Louis Dionne 2013-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. -->
  6. <!-- boost-no-inspect -->
  7. <!-- HTML header for doxygen 1.8.9.1-->
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  12. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  13. <meta name="generator" content="Doxygen 1.8.15"/>
  14. <title>Boost.Hana: boost::hana::type&lt; T &gt; Struct Template Reference</title>
  15. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  16. <script type="text/javascript" src="jquery.js"></script>
  17. <script type="text/javascript" src="dynsections.js"></script>
  18. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  19. <script type="text/javascript" src="resize.js"></script>
  20. <script type="text/javascript" src="navtreedata.js"></script>
  21. <script type="text/javascript" src="navtree.js"></script>
  22. <script type="text/javascript">
  23. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  24. $(document).ready(initResizable);
  25. /* @license-end */</script>
  26. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  27. <script type="text/javascript" src="search/searchdata.js"></script>
  28. <script type="text/javascript" src="search/search.js"></script>
  29. <script type="text/javascript">
  30. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  31. $(document).ready(function() { init_search(); });
  32. /* @license-end */
  33. </script>
  34. <script type="text/x-mathjax-config">
  35. MathJax.Hub.Config({
  36. extensions: ["tex2jax.js"],
  37. jax: ["input/TeX","output/HTML-CSS"],
  38. });
  39. // Copyright Louis Dionne 2013-2017
  40. // Distributed under the Boost Software License, Version 1.0.
  41. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  42. MathJax.Hub.Config({
  43. "HTML-CSS": {
  44. linebreaks: {
  45. automatic: true,
  46. width: "75% container"
  47. }
  48. }
  49. });
  50. </script><script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
  51. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  52. <!-- Additional javascript for drawing charts. -->
  53. <script type="text/javascript" src="highcharts.js"></script>
  54. <script type="text/javascript" src="highcharts-data.js"></script>
  55. <script type="text/javascript" src="highcharts-exporting.js"></script>
  56. <script type="text/javascript" src="chart.js"></script>
  57. <script type="text/javascript" src="hana.js"></script>
  58. </head>
  59. <body>
  60. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  61. <div id="titlearea">
  62. <table cellspacing="0" cellpadding="0">
  63. <tbody>
  64. <tr style="height: 56px;">
  65. <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  66. <td style="padding-left: 0.5em;">
  67. <div id="projectname">Boost.Hana
  68. &#160;<span id="projectnumber">1.6.0</span>
  69. </div>
  70. <div id="projectbrief">Your standard library for metaprogramming</div>
  71. </td>
  72. <td> <div id="MSearchBox" class="MSearchBoxInactive">
  73. <span class="left">
  74. <img id="MSearchSelect" src="search/mag_sel.png"
  75. onmouseover="return searchBox.OnSearchSelectShow()"
  76. onmouseout="return searchBox.OnSearchSelectHide()"
  77. alt=""/>
  78. <input type="text" id="MSearchField" value="Search" accesskey="S"
  79. onfocus="searchBox.OnSearchFieldFocus(true)"
  80. onblur="searchBox.OnSearchFieldFocus(false)"
  81. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  82. </span><span class="right">
  83. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  84. </span>
  85. </div>
  86. </td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. </div>
  91. <!-- end header part -->
  92. <!-- Generated by Doxygen 1.8.15 -->
  93. <script type="text/javascript">
  94. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  95. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  96. /* @license-end */
  97. </script>
  98. </div><!-- top -->
  99. <div id="side-nav" class="ui-resizable side-nav-resizable">
  100. <div id="nav-tree">
  101. <div id="nav-tree-contents">
  102. <div id="nav-sync" class="sync"></div>
  103. </div>
  104. </div>
  105. <div id="splitbar" style="-moz-user-select:none;"
  106. class="ui-resizable-handle">
  107. </div>
  108. </div>
  109. <script type="text/javascript">
  110. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  111. $(document).ready(function(){initNavTree('structboost_1_1hana_1_1type.html','');});
  112. /* @license-end */
  113. </script>
  114. <div id="doc-content">
  115. <!-- window showing the filter options -->
  116. <div id="MSearchSelectWindow"
  117. onmouseover="return searchBox.OnSearchSelectShow()"
  118. onmouseout="return searchBox.OnSearchSelectHide()"
  119. onkeydown="return searchBox.OnSearchSelectKey(event)">
  120. </div>
  121. <!-- iframe showing the search results (closed by default) -->
  122. <div id="MSearchResultsWindow">
  123. <iframe src="javascript:void(0)" frameborder="0"
  124. name="MSearchResults" id="MSearchResults">
  125. </iframe>
  126. </div>
  127. <div class="header">
  128. <div class="summary">
  129. <a href="#related">Synopsis of associated functions</a> &#124;
  130. <a href="#friends">Friends</a> &#124;
  131. <a href="#pub-methods">Public Member Functions</a> &#124;
  132. <a href="structboost_1_1hana_1_1type-members.html">List of all members</a> </div>
  133. <div class="headertitle">
  134. <div class="title">boost::hana::type&lt; T &gt; Struct Template Reference<div class="ingroups"><a class="el" href="group__group-datatypes.html">Data types</a></div></div> </div>
  135. </div><!--header-->
  136. <div class="contents">
  137. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  138. <div class="textblock"><h3>template&lt;typename T&gt;<br />
  139. struct boost::hana::type&lt; T &gt;</h3>
  140. <p>C++ type in value-level representation. </p>
  141. <p>A <code>type</code> is a special kind of object representing a C++ type like <code>int</code>, <code>void</code>, <code>std::vector&lt;float&gt;</code> or anything else you can imagine.</p>
  142. <p>This page explains how <code>type</code>s work at a low level. To gain intuition about type-level metaprogramming in Hana, you should read the <a class="el" href="index.html#tutorial-type">tutorial section</a> on type-level computations.</p>
  143. <dl class="section note"><dt>Note</dt><dd>For subtle reasons, the actual representation of <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> is implementation-defined. In particular, <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> may be a dependent type, so one should not attempt to do pattern matching on it. However, one can assume that <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> <em>inherits</em> from <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>, which can be useful when declaring overloaded functions: <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="keywordtype">void</span> f(hana::basic_type&lt;T&gt;) {</div><div class="line"> <span class="comment">// do something with T</span></div><div class="line">}</div></div><!-- fragment --> The full story is that <a href="http://en.cppreference.com/w/cpp/language/adl">ADL</a> causes template arguments to be instantiated. Hence, if <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> were defined naively, expressions like <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a>&lt;T&gt;{} == <a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a>&lt;U&gt;{}</code> would cause both <code>T</code> and <code>U</code> to be instantiated. This is usually not a problem, except when <code>T</code> or <code>U</code> should not be instantiated. To avoid these instantiations, <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> is implemented using some cleverness, and that is why the representation is implementation-defined. When that behavior is not required, <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> can be used instead.</dd></dl>
  144. <p><a class="anchor" id="type_lvalues_and_rvalues"></a></p><h2>Lvalues and rvalues </h2>
  145. <p>When storing <code>type</code>s in heterogeneous containers, some algorithms will return references to those objects. Since we are primarily interested in accessing their nested <code>::type</code>, receiving a reference is undesirable; we would end up trying to fetch the nested <code>::type</code> inside a reference type, which is a compilation error: </p><div class="fragment"><div class="line"><span class="keyword">auto</span> ts = make_tuple(type_c&lt;int&gt;, type_c&lt;char&gt;);</div><div class="line"><span class="keyword">using</span> T = decltype(ts[0_c])::type; <span class="comment">// error: &#39;ts[0_c]&#39; is a reference!</span></div></div><!-- fragment --><p>For this reason, <code>type</code>s provide an overload of the unary <code>+</code> operator that can be used to turn a lvalue into a rvalue. So when using a result which might be a reference to a <code>type</code> object, one can use <code>+</code> to make sure a rvalue is obtained before fetching its nested <code>::type</code>: </p><div class="fragment"><div class="line"><span class="keyword">auto</span> ts = make_tuple(type_c&lt;int&gt;, type_c&lt;char&gt;);</div><div class="line"><span class="keyword">using</span> T = decltype(+ts[0_c])::type; <span class="comment">// ok: &#39;+ts[0_c]&#39; is an rvalue</span></div></div><!-- fragment --><h2>Modeled concepts </h2>
  146. <ol type="1">
  147. <li><code>Comparable</code><br />
  148. Two types are equal if and only if they represent the same C++ type. Hence, equality is equivalent to the <code>std::is_same</code> type trait. <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="not__equal_8hpp.html">boost/hana/not_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"><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>T;</div><div class="line"><span class="keyword">struct </span>U;</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::type_c&lt;T&gt; == hana::type_c&lt;T&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::type_c&lt;T&gt; != hana::type_c&lt;U&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
  149. <li><code>Hashable</code><br />
  150. The hash of a type is just that type itself. In other words, <code>hash</code> is the identity function on <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>s. <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="hash_8hpp.html">boost/hana/hash.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// `hana::hash` is the identity on `hana::type`s.</span></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(</div><div class="line"> <a class="code" href="group__group-Hashable.html#ga6e906f44f47b210615491385e5c8a7b5">hana::hash</a>(hana::type_c&lt;int&gt;),</div><div class="line"> hana::type_c&lt;int&gt;</div><div class="line">));</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(</div><div class="line"> <a class="code" href="group__group-Hashable.html#ga6e906f44f47b210615491385e5c8a7b5">hana::hash</a>(hana::type_c&lt;void&gt;),</div><div class="line"> hana::type_c&lt;void&gt;</div><div class="line">));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --> </li>
  151. </ol>
  152. </div><table class="memberdecls">
  153. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="related"></a>
  154. Synopsis of associated functions</h2></td></tr>
  155. <tr class="memitem:ae35139e732c4b75e91061513cf445628"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
  156. <tr class="memitem:ae35139e732c4b75e91061513cf445628"><td class="memTemplItemLeft" align="right" valign="top">constexpr <a class="el" href="structboost_1_1hana_1_1type.html">type</a>&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#ae35139e732c4b75e91061513cf445628">type_c</a> {}</td></tr>
  157. <tr class="memdesc:ae35139e732c4b75e91061513cf445628"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates an object representing the C++ type <code>T</code>. <a href="#ae35139e732c4b75e91061513cf445628">More...</a><br /></td></tr>
  158. <tr class="separator:ae35139e732c4b75e91061513cf445628"><td class="memSeparator" colspan="2">&#160;</td></tr>
  159. <tr class="memitem:a7d68ff2275cbb295556d83598f04e39a"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a7d68ff2275cbb295556d83598f04e39a">decltype_</a> = see documentation</td></tr>
  160. <tr class="memdesc:a7d68ff2275cbb295556d83598f04e39a"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>decltype</code> keyword, lifted to Hana. <a href="#a7d68ff2275cbb295556d83598f04e39a">More...</a><br /></td></tr>
  161. <tr class="separator:a7d68ff2275cbb295556d83598f04e39a"><td class="memSeparator" colspan="2">&#160;</td></tr>
  162. <tr class="memitem:a0ade557ac4240552c92bf47c7e04dfd4"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a0ade557ac4240552c92bf47c7e04dfd4">typeid_</a> = see documentation</td></tr>
  163. <tr class="memdesc:a0ade557ac4240552c92bf47c7e04dfd4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> representing the type of a given object. <a href="#a0ade557ac4240552c92bf47c7e04dfd4">More...</a><br /></td></tr>
  164. <tr class="separator:a0ade557ac4240552c92bf47c7e04dfd4"><td class="memSeparator" colspan="2">&#160;</td></tr>
  165. <tr class="memitem:a66f97c1903dcb6f227b29f3e35e68a56"><td class="memTemplParams" colspan="2">template&lt;&gt; </td></tr>
  166. <tr class="memitem:a66f97c1903dcb6f227b29f3e35e68a56"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a66f97c1903dcb6f227b29f3e35e68a56">make&lt; type_tag &gt;</a> = hana::decltype_</td></tr>
  167. <tr class="memdesc:a66f97c1903dcb6f227b29f3e35e68a56"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code>decltype_</code>, provided for convenience. <a href="#a66f97c1903dcb6f227b29f3e35e68a56">More...</a><br /></td></tr>
  168. <tr class="separator:a66f97c1903dcb6f227b29f3e35e68a56"><td class="memSeparator" colspan="2">&#160;</td></tr>
  169. <tr class="memitem:a0c0e00c0ffe63703f3a04960d13c7b1c"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a0c0e00c0ffe63703f3a04960d13c7b1c">make_type</a> = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">hana::make</a>&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html">type_tag</a>&gt;</td></tr>
  170. <tr class="memdesc:a0c0e00c0ffe63703f3a04960d13c7b1c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type.">type_tag</a>&gt;</code>, provided for convenience. <a href="#a0c0e00c0ffe63703f3a04960d13c7b1c">More...</a><br /></td></tr>
  171. <tr class="separator:a0c0e00c0ffe63703f3a04960d13c7b1c"><td class="memSeparator" colspan="2">&#160;</td></tr>
  172. <tr class="memitem:a26b702b280ca02f118affaaca9112a8c"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a26b702b280ca02f118affaaca9112a8c">sizeof_</a></td></tr>
  173. <tr class="memdesc:a26b702b280ca02f118affaaca9112a8c"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>sizeof</code> keyword, lifted to Hana. <a href="#a26b702b280ca02f118affaaca9112a8c">More...</a><br /></td></tr>
  174. <tr class="separator:a26b702b280ca02f118affaaca9112a8c"><td class="memSeparator" colspan="2">&#160;</td></tr>
  175. <tr class="memitem:a6fd9ac456f4b5574dcb16384dbb85736"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a6fd9ac456f4b5574dcb16384dbb85736">alignof_</a></td></tr>
  176. <tr class="memdesc:a6fd9ac456f4b5574dcb16384dbb85736"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>alignof</code> keyword, lifted to Hana. <a href="#a6fd9ac456f4b5574dcb16384dbb85736">More...</a><br /></td></tr>
  177. <tr class="separator:a6fd9ac456f4b5574dcb16384dbb85736"><td class="memSeparator" colspan="2">&#160;</td></tr>
  178. <tr class="memitem:a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">is_valid</a></td></tr>
  179. <tr class="memdesc:a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks whether a SFINAE-friendly expression is valid. <a href="#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">More...</a><br /></td></tr>
  180. <tr class="separator:a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"><td class="memSeparator" colspan="2">&#160;</td></tr>
  181. </table><table class="memberdecls">
  182. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
  183. Friends</h2></td></tr>
  184. <tr class="memitem:a27607958295e6da8a0ba602a2db468f1"><td class="memTemplParams" colspan="2"><a id="a27607958295e6da8a0ba602a2db468f1"></a>
  185. template&lt;typename X , typename Y &gt; </td></tr>
  186. <tr class="memitem:a27607958295e6da8a0ba602a2db468f1"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  187. <tr class="memdesc:a27607958295e6da8a0ba602a2db468f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547" title="Returns a Logical representing whether x is equal to y.The equal function can be called in two differ...">hana::equal</a></code> <br /></td></tr>
  188. <tr class="separator:a27607958295e6da8a0ba602a2db468f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
  189. <tr class="memitem:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memTemplParams" colspan="2"><a id="a0cae3af55edb3eb05bfa184bda633f7d"></a>
  190. template&lt;typename X , typename Y &gt; </td></tr>
  191. <tr class="memitem:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
  192. <tr class="memdesc:a0cae3af55edb3eb05bfa184bda633f7d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd" title="Returns a Logical representing whether x is not equal to y.The not_equal function can be called in tw...">hana::not_equal</a></code> <br /></td></tr>
  193. <tr class="separator:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  194. </table><table class="memberdecls">
  195. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
  196. Public Member Functions</h2></td></tr>
  197. <tr class="memitem:a228c1b24d16b2c765c816f816a09337c"><td class="memItemLeft" align="right" valign="top"><a id="a228c1b24d16b2c765c816f816a09337c"></a>
  198. constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a228c1b24d16b2c765c816f816a09337c">operator+</a> () const</td></tr>
  199. <tr class="memdesc:a228c1b24d16b2c765c816f816a09337c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns rvalue of self. See <a class="el" href="structboost_1_1hana_1_1type.html#type_lvalues_and_rvalues">description</a>. <br /></td></tr>
  200. <tr class="separator:a228c1b24d16b2c765c816f816a09337c"><td class="memSeparator" colspan="2">&#160;</td></tr>
  201. </table>
  202. <h2 class="groupheader">Associated functions</h2>
  203. <a id="ae35139e732c4b75e91061513cf445628"></a>
  204. <h2 class="memtitle"><span class="permalink"><a href="#ae35139e732c4b75e91061513cf445628">&#9670;&nbsp;</a></span>type_c</h2>
  205. <div class="memitem">
  206. <div class="memproto">
  207. <div class="memtemplate">
  208. template&lt;typename T &gt; </div>
  209. <div class="memtemplate">
  210. template&lt;typename T &gt; </div>
  211. <table class="mlabels">
  212. <tr>
  213. <td class="mlabels-left">
  214. <table class="memname">
  215. <tr>
  216. <td class="memname">constexpr <a class="el" href="structboost_1_1hana_1_1type.html">type</a>&lt;T&gt; type_c {}</td>
  217. </tr>
  218. </table>
  219. </td>
  220. <td class="mlabels-right">
  221. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  222. </tr>
  223. </table>
  224. </div><div class="memdoc">
  225. <p>Creates an object representing the C++ type <code>T</code>. </p>
  226. </div>
  227. </div>
  228. <a id="a7d68ff2275cbb295556d83598f04e39a"></a>
  229. <h2 class="memtitle"><span class="permalink"><a href="#a7d68ff2275cbb295556d83598f04e39a">&#9670;&nbsp;</a></span>decltype_</h2>
  230. <div class="memitem">
  231. <div class="memproto">
  232. <div class="memtemplate">
  233. template&lt;typename T &gt; </div>
  234. <table class="mlabels">
  235. <tr>
  236. <td class="mlabels-left">
  237. <table class="memname">
  238. <tr>
  239. <td class="memname">constexpr auto decltype_ = see documentation</td>
  240. </tr>
  241. </table>
  242. </td>
  243. <td class="mlabels-right">
  244. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  245. </tr>
  246. </table>
  247. </div><div class="memdoc">
  248. <p><code>decltype</code> keyword, lifted to Hana. </p>
  249. <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000001">Deprecated:</a></b></dt><dd>The semantics of <code>decltype_</code> can be confusing, and <code>hana::typeid_</code> should be preferred instead. <code>decltype_</code> may be removed in the next major version of the library.</dd></dl>
  250. <p><code>decltype_</code> is somewhat equivalent to <code>decltype</code> in that it returns the type of an object, except it returns it as a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> which is a first-class citizen of Hana instead of a raw C++ type. Specifically, given an object <code>x</code>, <code>decltype_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a7d68ff2275cbb295556d83598f04e39a">decltype_</a>(x) == <a class="code" href="structboost_1_1hana_1_1type.html#ae35139e732c4b75e91061513cf445628">type_c</a>&lt;decltype(x) with references stripped&gt;</div></div><!-- fragment --><p>As you can see, <code>decltype_</code> will strip any reference from the object's actual type. The reason for doing so is explained below. However, any <code>cv</code>-qualifiers will be retained. Also, when given a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>, <code>decltype_</code> is just the identity function. Hence, for any C++ type <code>T</code>, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a7d68ff2275cbb295556d83598f04e39a">decltype_</a>(type_c&lt;T&gt;) == type_c&lt;T&gt;</div></div><!-- fragment --><p>In conjunction with the way <code>metafunction</code> &amp; al. are specified, this behavior makes it easier to interact with both types and values at the same time. However, it does make it impossible to create a <code>type</code> containing another <code>type</code> with <code>decltype_</code>. In other words, it is not possible to create a <code>type_c&lt;decltype(type_c&lt;T&gt;)&gt;</code> with this utility, because <code>decltype_(type_c&lt;T&gt;)</code> would be just <code>type_c&lt;T&gt;</code> instead of <code>type_c&lt;decltype(type_c&lt;T&gt;)&gt;</code>. This use case is assumed to be rare and a hand-coded function can be used if this is needed.</p>
  251. <h3>Rationale for stripping the references</h3>
  252. <p>The rules for template argument deduction are such that a perfect solution that always matches <code>decltype</code> is impossible. Hence, we have to settle on a solution that's good and and consistent enough for our needs. One case where matching <code>decltype</code>'s behavior is impossible is when the argument is a plain, unparenthesized variable or function parameter. In that case, <code>decltype_</code>'s argument will be deduced as a reference to that variable, but <code>decltype</code> would have given us the actual type of that variable, without references. Also, given the current definition of <code>metafunction</code> &amp; al., it would be mostly useless if <code>decltype_</code> could return a reference, because it is unlikely that <code>F</code> expects a reference in its simplest use case: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> i = 0;</div><div class="line"><span class="keyword">auto</span> result = metafunction&lt;F&gt;(i);</div></div><!-- fragment --><p>Hence, always discarding references seems to be the least painful solution.</p>
  253. <h2>Example </h2>
  254. <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"><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>X { };</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(1) == hana::type_c&lt;int&gt;);</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> <span class="keyword">const</span>&amp; i = 1;</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(i) == hana::type_c&lt;int const&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  255. </div>
  256. </div>
  257. <a id="a0ade557ac4240552c92bf47c7e04dfd4"></a>
  258. <h2 class="memtitle"><span class="permalink"><a href="#a0ade557ac4240552c92bf47c7e04dfd4">&#9670;&nbsp;</a></span>typeid_</h2>
  259. <div class="memitem">
  260. <div class="memproto">
  261. <div class="memtemplate">
  262. template&lt;typename T &gt; </div>
  263. <table class="mlabels">
  264. <tr>
  265. <td class="mlabels-left">
  266. <table class="memname">
  267. <tr>
  268. <td class="memname">constexpr auto typeid_ = see documentation</td>
  269. </tr>
  270. </table>
  271. </td>
  272. <td class="mlabels-right">
  273. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  274. </tr>
  275. </table>
  276. </div><div class="memdoc">
  277. <p>Returns a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> representing the type of a given object. </p>
  278. <p><code>hana::typeid_</code> is somewhat similar to <code>typeid</code> in that it returns something that represents the type of an object. However, what <code>typeid</code> returns represent the <em>runtime</em> type of the object, while <code>hana::typeid_</code> returns the <em>static</em> type of the object. Specifically, given an object <code>x</code>, <code>typeid_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a0ade557ac4240552c92bf47c7e04dfd4">typeid_</a>(x) == <a class="code" href="structboost_1_1hana_1_1type.html#ae35139e732c4b75e91061513cf445628">type_c</a>&lt;decltype(x) with ref and cv-qualifiers stripped&gt;</div></div><!-- fragment --><p>As you can see, <code>typeid_</code> strips any reference and cv-qualifier from the object's actual type. The reason for doing so is that it faithfully models how the language's <code>typeid</code> behaves with respect to reference and cv-qualifiers, and it also turns out to be the desirable behavior most of the time. Also, when given a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>, <code>typeid_</code> is just the identity function. Hence, for any C++ type <code>T</code>, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a0ade557ac4240552c92bf47c7e04dfd4">typeid_</a>(type_c&lt;T&gt;) == type_c&lt;T&gt;</div></div><!-- fragment --><p>In conjunction with the way <code>metafunction</code> &amp; al. are specified, this behavior makes it easier to interact with both types and values at the same time. However, it does make it impossible to create a <code>type</code> containing another <code>type</code> using <code>typeid_</code>. This use case is assumed to be rare and a hand-coded function can be used if this is needed.</p>
  279. <h2>Example </h2>
  280. <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="remove__if_8hpp.html">boost/hana/remove_if.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;string&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>Cat { std::string name; };</div><div class="line"><span class="keyword">struct </span>Dog { std::string name; };</div><div class="line"><span class="keyword">struct </span>Fish { std::string name; };</div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a>(Cat <span class="keyword">const</span>&amp; a, Cat <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name == b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a>(Cat <span class="keyword">const</span>&amp; a, Cat <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name != b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a>(Dog <span class="keyword">const</span>&amp; a, Dog <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name == b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a>(Dog <span class="keyword">const</span>&amp; a, Dog <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name != b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a>(Fish <span class="keyword">const</span>&amp; a, Fish <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name == b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a>(Fish <span class="keyword">const</span>&amp; a, Fish <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name != b.name; }</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line"> hana::tuple&lt;Cat, Fish, Dog, Fish&gt; animals{</div><div class="line"> Cat{<span class="stringliteral">&quot;Garfield&quot;</span>}, Fish{<span class="stringliteral">&quot;Jaws&quot;</span>}, Dog{<span class="stringliteral">&quot;Beethoven&quot;</span>}, Fish{<span class="stringliteral">&quot;Nemo&quot;</span>}</div><div class="line"> };</div><div class="line"></div><div class="line"> <span class="keyword">auto</span> mammals = <a class="code" href="group__group-MonadPlus.html#ga9700169a45664d50377c1be9d58accd3">hana::remove_if</a>(animals, [](<span class="keyword">auto</span> <span class="keyword">const</span>&amp; a) {</div><div class="line"> <span class="keywordflow">return</span> hana::typeid_(a) == hana::type&lt;Fish&gt;{};</div><div class="line"> });</div><div class="line"></div><div class="line"> <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(mammals == hana::make_tuple(Cat{<span class="stringliteral">&quot;Garfield&quot;</span>}, Dog{<span class="stringliteral">&quot;Beethoven&quot;</span>}));</div><div class="line">}</div></div><!-- fragment -->
  281. </div>
  282. </div>
  283. <a id="a66f97c1903dcb6f227b29f3e35e68a56"></a>
  284. <h2 class="memtitle"><span class="permalink"><a href="#a66f97c1903dcb6f227b29f3e35e68a56">&#9670;&nbsp;</a></span>make&lt; type_tag &gt;</h2>
  285. <div class="memitem">
  286. <div class="memproto">
  287. <div class="memtemplate">
  288. template&lt;typename T &gt; </div>
  289. <div class="memtemplate">
  290. template&lt;&gt; </div>
  291. <table class="mlabels">
  292. <tr>
  293. <td class="mlabels-left">
  294. <table class="memname">
  295. <tr>
  296. <td class="memname">constexpr auto <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt; <a class="el" href="structboost_1_1hana_1_1type__tag.html">type_tag</a> &gt; = hana::decltype_</td>
  297. </tr>
  298. </table>
  299. </td>
  300. <td class="mlabels-right">
  301. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  302. </tr>
  303. </table>
  304. </div><div class="memdoc">
  305. <p>Equivalent to <code>decltype_</code>, provided for convenience. </p>
  306. <h2>Example </h2>
  307. <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="core_2make_8hpp.html">boost/hana/core/make.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"><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>X { };</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  308. </div>
  309. </div>
  310. <a id="a0c0e00c0ffe63703f3a04960d13c7b1c"></a>
  311. <h2 class="memtitle"><span class="permalink"><a href="#a0c0e00c0ffe63703f3a04960d13c7b1c">&#9670;&nbsp;</a></span>make_type</h2>
  312. <div class="memitem">
  313. <div class="memproto">
  314. <div class="memtemplate">
  315. template&lt;typename T &gt; </div>
  316. <table class="mlabels">
  317. <tr>
  318. <td class="mlabels-left">
  319. <table class="memname">
  320. <tr>
  321. <td class="memname">constexpr auto make_type = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">hana::make</a>&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html">type_tag</a>&gt;</td>
  322. </tr>
  323. </table>
  324. </td>
  325. <td class="mlabels-right">
  326. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  327. </tr>
  328. </table>
  329. </div><div class="memdoc">
  330. <p>Equivalent to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type.">type_tag</a>&gt;</code>, provided for convenience. </p>
  331. <h2>Example </h2>
  332. <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="core_2make_8hpp.html">boost/hana/core/make.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"><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>X { };</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  333. </div>
  334. </div>
  335. <a id="a26b702b280ca02f118affaaca9112a8c"></a>
  336. <h2 class="memtitle"><span class="permalink"><a href="#a26b702b280ca02f118affaaca9112a8c">&#9670;&nbsp;</a></span>sizeof_</h2>
  337. <div class="memitem">
  338. <div class="memproto">
  339. <div class="memtemplate">
  340. template&lt;typename T &gt; </div>
  341. <table class="mlabels">
  342. <tr>
  343. <td class="mlabels-left">
  344. <table class="memname">
  345. <tr>
  346. <td class="memname">constexpr auto sizeof_</td>
  347. </tr>
  348. </table>
  349. </td>
  350. <td class="mlabels-right">
  351. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  352. </tr>
  353. </table>
  354. </div><div class="memdoc">
  355. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div><div class="line"> <span class="keyword">using</span> T = <span class="keyword">typename</span> decltype(hana::decltype_(x))::type;</div><div class="line"> <span class="keywordflow">return</span> hana::size_c&lt;<span class="keyword">sizeof</span>(T)&gt;;</div><div class="line"> }</div></div><!-- fragment -->
  356. <p><code>sizeof</code> keyword, lifted to Hana. </p>
  357. <p><code>sizeof_</code> is somewhat equivalent to <code>sizeof</code> in that it returns the size of an expression or type, but it takes an arbitrary expression or a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> and returns its size as an <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">integral_constant</a></code>. Specifically, given an expression <code>expr</code>, <code>sizeof_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a26b702b280ca02f118affaaca9112a8c">sizeof_</a>(expr) == <span class="keywordtype">size_t</span>&lt;<span class="keyword">sizeof</span>(decltype(expr) with references stripped)&gt;</div></div><!-- fragment --><p>However, given a <code>type</code>, <code>sizeof_</code> will simply fetch the size of the C++ type represented by that object. In other words, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a26b702b280ca02f118affaaca9112a8c">sizeof_</a>(type_c&lt;T&gt;) == <span class="keywordtype">size_t</span>&lt;<span class="keyword">sizeof</span>(T)&gt;</div></div><!-- fragment --><p>The behavior of <code>sizeof_</code> is consistent with that of <code>decltype_</code>. In particular, see <code>decltype_</code>'s documentation to understand why references are always stripped by <code>sizeof_</code>.</p>
  358. <h2>Example </h2>
  359. <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="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"><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>X { };</div><div class="line">static_assert(hana::sizeof_(hana::type_c&lt;X&gt;) == <span class="keyword">sizeof</span>(X), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line">static_assert(hana::sizeof_(1) == <span class="keyword">sizeof</span>(1), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::sizeof_(hana::type_c&lt;int&gt;) == <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {}</div></div><!-- fragment -->
  360. </div>
  361. </div>
  362. <a id="a6fd9ac456f4b5574dcb16384dbb85736"></a>
  363. <h2 class="memtitle"><span class="permalink"><a href="#a6fd9ac456f4b5574dcb16384dbb85736">&#9670;&nbsp;</a></span>alignof_</h2>
  364. <div class="memitem">
  365. <div class="memproto">
  366. <div class="memtemplate">
  367. template&lt;typename T &gt; </div>
  368. <table class="mlabels">
  369. <tr>
  370. <td class="mlabels-left">
  371. <table class="memname">
  372. <tr>
  373. <td class="memname">constexpr auto alignof_</td>
  374. </tr>
  375. </table>
  376. </td>
  377. <td class="mlabels-right">
  378. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  379. </tr>
  380. </table>
  381. </div><div class="memdoc">
  382. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div><div class="line"> <span class="keyword">using</span> T = <span class="keyword">typename</span> decltype(hana::decltype_(x))::type;</div><div class="line"> <span class="keywordflow">return</span> hana::size_c&lt;<span class="keyword">alignof</span>(T)&gt;;</div><div class="line"> }</div></div><!-- fragment -->
  383. <p><code>alignof</code> keyword, lifted to Hana. </p>
  384. <p><code>alignof_</code> is somewhat equivalent to <code>alignof</code> in that it returns the alignment required by any instance of a type, but it takes a <code>type</code> and returns its alignment as an <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">integral_constant</a></code>. Like <code>sizeof</code> which works for expressions and type-ids, <code>alignof_</code> can also be called on an arbitrary expression. Specifically, given an expression <code>expr</code> and a C++ type <code>T</code>, <code>alignof_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a6fd9ac456f4b5574dcb16384dbb85736">alignof_</a>(expr) == <span class="keywordtype">size_t</span>&lt;<span class="keyword">alignof</span>(decltype(expr) with references stripped)&gt;</div><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a6fd9ac456f4b5574dcb16384dbb85736">alignof_</a>(type_c&lt;T&gt;) == <span class="keywordtype">size_t</span>&lt;<span class="keyword">alignof</span>(T)&gt;</div></div><!-- fragment --><p>The behavior of <code>alignof_</code> is consistent with that of <code>decltype_</code>. In particular, see <code>decltype_</code>'s documentation to understand why references are always stripped by <code>alignof_</code>.</p>
  385. <h2>Example </h2>
  386. <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="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"><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>X { };</div><div class="line">static_assert(hana::alignof_(hana::type_c&lt;X&gt;) == <span class="keyword">alignof</span>(X), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line">static_assert(hana::alignof_(1) == <span class="keyword">alignof</span>(decltype(1)), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::alignof_(hana::type_c&lt;int&gt;) == <span class="keyword">alignof</span>(<span class="keywordtype">int</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
  387. </div>
  388. </div>
  389. <a id="a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"></a>
  390. <h2 class="memtitle"><span class="permalink"><a href="#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">&#9670;&nbsp;</a></span>is_valid</h2>
  391. <div class="memitem">
  392. <div class="memproto">
  393. <div class="memtemplate">
  394. template&lt;typename T &gt; </div>
  395. <table class="mlabels">
  396. <tr>
  397. <td class="mlabels-left">
  398. <table class="memname">
  399. <tr>
  400. <td class="memname">constexpr auto is_valid</td>
  401. </tr>
  402. </table>
  403. </td>
  404. <td class="mlabels-right">
  405. <span class="mlabels"><span class="mlabel">related</span></span> </td>
  406. </tr>
  407. </table>
  408. </div><div class="memdoc">
  409. <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; f) {</div><div class="line"> <span class="keywordflow">return</span> [](<span class="keyword">auto</span>&amp;&amp; ...args) {</div><div class="line"> <span class="keywordflow">return</span> whether f(args...) is a valid expression;</div><div class="line"> };</div><div class="line"> }</div></div><!-- fragment -->
  410. <p>Checks whether a SFINAE-friendly expression is valid. </p>
  411. <p>Given a SFINAE-friendly function, <code>is_valid</code> returns whether the function call is valid with the given arguments. Specifically, given a function <code>f</code> and arguments <code>args...</code>, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">is_valid</a>(f, args...) == whether f(args...) is valid</div></div><!-- fragment --><p>The result is returned as a compile-time <code>Logical</code>. Furthermore, <code>is_valid</code> can be used in curried form as follows: </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">is_valid</a>(f)(args...)</div></div><!-- fragment --><p>This syntax makes it easy to create functions that check the validity of a generic expression on any given argument(s).</p>
  412. <dl class="section warning"><dt>Warning</dt><dd>To check whether calling a nullary function <code>f</code> is valid, one should use the <code>is_valid(f)()</code> syntax. Indeed, <code>is_valid(f /* no args */)</code> will be interpreted as the currying of <code>is_valid</code> to <code>f</code> rather than the application of <code>is_valid</code> to <code>f</code> and no arguments.</dd></dl>
  413. <h2>Example </h2>
  414. <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="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;string&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;vector&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="keywordtype">int</span> main() {</div><div class="line"> <span class="comment">// Checking for a member</span></div><div class="line"> <span class="keyword">struct </span>Person { std::string name; };</div><div class="line"> <span class="keyword">auto</span> has_name = hana::is_valid([](<span class="keyword">auto</span>&amp;&amp; p) -&gt; decltype((<span class="keywordtype">void</span>)p.name) { });</div><div class="line"></div><div class="line"> Person joe{<span class="stringliteral">&quot;Joe&quot;</span>};</div><div class="line"> static_assert(has_name(joe), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> static_assert(!has_name(1), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// Checking for a nested type</span></div><div class="line"> <span class="keyword">auto</span> has_value_type = hana::is_valid([](<span class="keyword">auto</span> t) -&gt; hana::type&lt;</div><div class="line"> <span class="keyword">typename</span> decltype(t)::type::value_type</div><div class="line"> &gt; { });</div><div class="line"></div><div class="line"> static_assert(has_value_type(hana::type_c&lt;std::vector&lt;int&gt;&gt;), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"> static_assert(!has_value_type(hana::type_c&lt;Person&gt;), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">}</div></div><!-- fragment -->
  415. </div>
  416. </div>
  417. </div><!-- contents -->
  418. </div><!-- doc-content -->
  419. <!--
  420. Copyright Louis Dionne 2013-2017
  421. Distributed under the Boost Software License, Version 1.0.
  422. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  423. -->
  424. <!-- boost-no-inspect -->
  425. <!-- HTML footer for doxygen 1.8.9.1-->
  426. <!-- start footer part -->
  427. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  428. <ul>
  429. <li class="navelem"><b>boost</b></li><li class="navelem"><a class="el" href="namespaceboost_1_1hana.html">hana</a></li><li class="navelem"><a class="el" href="structboost_1_1hana_1_1type.html">type</a></li>
  430. </ul>
  431. </div>
  432. </body>
  433. </html>