123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <!--
- 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: boost::mpl::vector< T > Struct Template Reference</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('structboost_1_1mpl_1_1vector.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="headertitle">
- <div class="title">boost::mpl::vector< T > Struct Template Reference<div class="ingroups"><a class="el" href="group__group-ext.html">External adapters</a> » <a class="el" href="group__group-ext-mpl.html">Boost.MPL adapters</a></div></div> </div>
- </div><!--header-->
- <div class="contents">
- <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
- <div class="textblock"><h3>template<typename ... T><br />
- struct boost::mpl::vector< T ></h3>
- <p>Adapter for Boost.MPL vectors. </p>
- <h2>Modeled concepts </h2>
- <p>It is possible for MPL vectors to model a couple of concepts. However, because they are only able to hold types, they lack the generality required to model concepts like <code>Functor</code>, <code>Sequence</code> and other related concepts.</p>
- <ol type="1">
- <li><code>Comparable</code><br />
- Two MPL vectors are equal if and only if they contain the same number of types, and if all those types are equal. <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="boost_2mpl_2vector_8hpp.html">boost/hana/ext/boost/mpl/vector.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <<a class="code" href="boost_2mpl_2vector_8hpp.html">boost/mpl/vector.hpp</a>></span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"><span class="keyword">namespace </span>mpl = boost::mpl;</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>(</div><div class="line"> <a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(mpl::vector2<int, char>{}, mpl::vector<int, char>{})</div><div class="line">);</div><div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div><div class="line"> <a class="code" href="group__group-Comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd">hana::not_equal</a>(mpl::vector2<int, char>{}, mpl::vector<int, char, float>{})</div><div class="line">);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
- <li><code>Foldable</code><br />
- Folding a MPL vector is equivalent to folding it as a <code>Sequence</code>. <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="boost_2mpl_2vector_8hpp.html">boost/hana/ext/boost/mpl/vector.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="fold__left_8hpp.html">boost/hana/fold_left.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="if_8hpp.html">boost/hana/if.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="plus_8hpp.html">boost/hana/plus.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 <<a class="code" href="boost_2mpl_2vector_8hpp.html">boost/mpl/vector.hpp</a>></span></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"><span class="keyword">namespace </span>mpl = boost::mpl;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">auto</span> types = mpl::vector<long, float, short, float, long, long double>{};</div><div class="line"><span class="keyword">auto</span> number_of_floats = <a class="code" href="group__group-Foldable.html#ga38c6b3f6b1cbadb9b8432a05ff16b7d2">hana::fold_left</a>(types, hana::int_c<0>, [](<span class="keyword">auto</span> <a class="code" href="group__group-Foldable.html#ga3159cfa41be18a396926741b0a3fdefd">count</a>, <span class="keyword">auto</span> t) {</div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="group__group-Logical.html#gafd655d2222367131e7a63616e93dd080">hana::if_</a>(hana::trait<std::is_floating_point>(t),</div><div class="line"> <a class="code" href="group__group-Foldable.html#ga3159cfa41be18a396926741b0a3fdefd">count</a> + hana::int_c<1>,</div><div class="line"> <a class="code" href="group__group-Foldable.html#ga3159cfa41be18a396926741b0a3fdefd">count</a></div><div class="line"> );</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>(number_of_floats == hana::int_c<3>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
- <li><code>Iterable</code><br />
- Iterating over a MPL vector is just iterating over each of the types it contains, as if it were a <code>Sequence</code>. <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="drop__front_8hpp.html">boost/hana/drop_front.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="drop__while_8hpp.html">boost/hana/drop_while.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="boost_2mpl_2vector_8hpp.html">boost/hana/ext/boost/mpl/vector.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="front_8hpp.html">boost/hana/front.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 <<a class="code" href="boost_2mpl_2vector_8hpp.html">boost/mpl/vector.hpp</a>></span></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"><span class="keyword">namespace </span>mpl = boost::mpl;</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-Iterable.html#ga8a67ea10e8082dbe6705e573fa978444">hana::front</a>(mpl::vector<int, char, void>{}) == hana::type_c<int>);</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-Iterable.html#gad23ce0a4906e2bb0a52f38837b134757">hana::drop_front</a>(mpl::vector<int, char, void>{}),</div><div class="line"> mpl::vector<char, void>{}</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-Iterable.html#ga9f1d02c74a6bdc1db260e0d6a8f1ee56">hana::drop_while</a>(mpl::vector<float, double const, int, float&>{},</div><div class="line"> hana::trait<std::is_floating_point>),</div><div class="line"> mpl::vector<int, float&>{}</div><div class="line">));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
- <li><code>Searchable</code><br />
- A MPL vector can be searched as if it were a tuple containing <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 <<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="boost_2mpl_2vector_8hpp.html">boost/hana/ext/boost/mpl/vector.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="find_8hpp.html">boost/hana/find.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="find__if_8hpp.html">boost/hana/find_if.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="optional_8hpp.html">boost/hana/optional.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 <<a class="code" href="boost_2mpl_2vector_8hpp.html">boost/mpl/vector.hpp</a>></span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"><span class="keyword">namespace </span>mpl = boost::mpl;</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>(</div><div class="line"> <a class="code" href="group__group-Searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(mpl::vector<int, float, char const*>{}, <a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>.to(hana::type_c<float>))</div><div class="line"> ==</div><div class="line"> hana::just(hana::type_c<float>)</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>(</div><div class="line"> <a class="code" href="group__group-Searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(mpl::vector<int, float, char const*>{}, hana::type_c<void>)</div><div class="line"> ==</div><div class="line"> hana::nothing</div><div class="line">);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
- </ol>
- <h2>Conversion from any <code>Foldable</code> </h2>
- <p>A MPL vector can be created from any <code>Foldable</code>. More precisely, for a <code>Foldable</code> <code>xs</code> whose linearization is <code>[x1, ..., xn]</code>, </p><div class="fragment"><div class="line">to<ext::boost::mpl::vector_tag>(xs) == mpl::vector<t1, ..., tn></div></div><!-- fragment --><p> where <code>tk</code> is the type of <code>xk</code>, or the type contained in <code>xk</code> if <code>xk</code> is a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>. </p><dl class="section warning"><dt>Warning</dt><dd>The limitations on the size of <code><a class="el" href="structboost_1_1mpl_1_1vector.html" title="Adapter for Boost.MPL vectors.">mpl::vector</a></code>s are inherited by this conversion utility, and hence trying to convert a <code>Foldable</code> containing more than <a href="http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/limit-vector-size.html">BOOST_MPL_LIMIT_VECTOR_SIZE</a> elements is an error. <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="core_2to_8hpp.html">boost/hana/core/to.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="boost_2mpl_2vector_8hpp.html">boost/hana/ext/boost/mpl/vector.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <<a class="code" href="boost_2mpl_2vector_8hpp.html">boost/mpl/vector.hpp</a>></span></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"><span class="keyword">namespace </span>mpl = boost::mpl;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">auto</span> xs = hana::make_tuple(hana::type_c<int>, hana::type_c<char>, hana::type_c<double>);</div><div class="line">static_assert(std::is_same<</div><div class="line"> decltype(hana::to<hana::ext::boost::mpl::vector_tag>(xs)),</div><div class="line"> mpl::vector<int, char, double></div><div class="line">>{}, <span class="stringliteral">""</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --> </dd></dl>
- </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>
- <li class="navelem"><b>boost</b></li><li class="navelem"><b>mpl</b></li><li class="navelem"><a class="el" href="structboost_1_1mpl_1_1vector.html">vector</a></li>
- </ul>
- </div>
- </body>
- </html>
|