range-c.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
  7. <title>The MPL Reference Manual: range_c</title>
  8. <link rel="stylesheet" href="../style.css" type="text/css" />
  9. </head>
  10. <body class="docframe refmanual">
  11. <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./map.html" class="navigation-link">Prev</a>&nbsp;<a href="./vector-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./map.html" class="navigation-link">Back</a>&nbsp;<a href="./vector-c.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./classes.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  12. <td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./classes.html" class="navigation-link">Classes</a> / <a href="./range-c.html" class="navigation-link">range_c</a></td>
  13. </tr></table><div class="header-separator"></div>
  14. <div class="section" id="range-c">
  15. <h1><a class="toc-backref" href="./classes.html#id1411">range_c</a></h1>
  16. <div class="section" id="synopsis">
  17. <h3>Synopsis</h3>
  18. <pre class="literal-block">
  19. template&lt;
  20. typename T
  21. , T Start
  22. , T Finish
  23. &gt;
  24. struct <a href="./range-c.html" class="identifier">range_c</a>
  25. {
  26. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;T,Start&gt; start;
  27. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;T,Finish&gt; finish;
  28. // <em>unspecified</em>
  29. // <em>...</em>
  30. };
  31. </pre>
  32. </div>
  33. <div class="section" id="id88">
  34. <h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
  35. <p><tt class="literal"><span class="pre"><a href="./range-c.html" class="identifier">range_c</a></span></tt> is a sorted <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a> of <a class="reference internal" href="./integral-constant.html">Integral Constant</a>s. Note
  36. that because it is not an <a class="reference internal" href="./extensible-sequence.html">Extensible Sequence</a>, sequence-building
  37. intrinsic metafunctions such as <tt class="literal"><span class="pre"><a href="./push-front.html" class="identifier">push_front</a></span></tt> and transformation algorithms
  38. such as <tt class="literal"><span class="pre"><a href="./replace.html" class="identifier">replace</a></span></tt> are not directly applicable — to be able to use
  39. them, you'd first need to copy the content of the range into a more suitable
  40. sequence.</p>
  41. </div>
  42. <div class="section" id="id89">
  43. <h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
  44. <pre class="literal-block">
  45. #include &lt;<a href="../../../../boost/mpl/range_c.hpp" class="header">boost/mpl/range_c.hpp</a>&gt;
  46. </pre>
  47. </div>
  48. <div class="section" id="id90">
  49. <h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
  50. <p><a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a></p>
  51. </div>
  52. <div class="section" id="id91">
  53. <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
  54. <p>In the following table, <tt class="literal"><span class="pre">r</span></tt> is an instance of <tt class="literal"><span class="pre"><a href="./range-c.html" class="identifier">range_c</a></span></tt>, <tt class="literal"><span class="pre">n</span></tt> is an <a class="reference internal" href="./integral-constant.html">Integral Constant</a>,
  55. <tt class="literal"><span class="pre">T</span></tt> is an arbitrary integral type, and <tt class="literal"><span class="pre">n</span></tt> and <tt class="literal"><span class="pre">m</span></tt> are integral constant values of type <tt class="literal"><span class="pre">T</span></tt>.</p>
  56. <table border="1" class="docutils table">
  57. <colgroup>
  58. <col width="34%" />
  59. <col width="66%" />
  60. </colgroup>
  61. <thead valign="bottom">
  62. <tr><th class="head">Expression</th>
  63. <th class="head">Semantics</th>
  64. </tr>
  65. </thead>
  66. <tbody valign="top">
  67. <tr><td><pre class="first last literal-block">
  68. <tt class="literal"><span class="pre"><a href="./range-c.html" class="identifier">range_c</a>&lt;T,n,m&gt;</span></tt>
  69. <tt class="literal"><span class="pre"><a href="./range-c.html" class="identifier">range_c</a>&lt;T,n,m&gt;::type</span></tt>
  70. </pre>
  71. </td>
  72. <td>A sorted <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a> of integral constant
  73. wrappers for the half-open range of values [<tt class="literal"><span class="pre">n</span></tt>,
  74. <tt class="literal"><span class="pre">m</span></tt>): <tt class="literal"><span class="pre"><a href="./integral-c.html" class="identifier">integral_c</a>&lt;T,n&gt;</span></tt>, <tt class="literal"><span class="pre"><a href="./integral-c.html" class="identifier">integral_c</a>&lt;T,n+1&gt;</span></tt>,...
  75. <tt class="literal"><span class="pre"><a href="./integral-c.html" class="identifier">integral_c</a>&lt;T,m-1&gt;</span></tt>.</td>
  76. </tr>
  77. <tr><td><tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;r&gt;::type</span></tt></td>
  78. <td>An iterator pointing to the beginning of <tt class="literal"><span class="pre">r</span></tt>;
  79. see <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  80. </tr>
  81. <tr><td><tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;r&gt;::type</span></tt></td>
  82. <td>An iterator pointing to the end of <tt class="literal"><span class="pre">r</span></tt>;
  83. see <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  84. </tr>
  85. <tr><td><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;r&gt;::type</span></tt></td>
  86. <td>The size of <tt class="literal"><span class="pre">r</span></tt>; see <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  87. </tr>
  88. <tr><td><tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;r&gt;::type</span></tt></td>
  89. <td>A boolean <a class="reference internal" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> such that
  90. <tt class="literal"><span class="pre">c::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> if and only if <tt class="literal"><span class="pre">r</span></tt> is empty; see
  91. <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  92. </tr>
  93. <tr><td><tt class="literal"><span class="pre"><a href="./front.html" class="identifier">front</a>&lt;r&gt;::type</span></tt></td>
  94. <td>The first element in <tt class="literal"><span class="pre">r</span></tt>; see
  95. <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  96. </tr>
  97. <tr><td><tt class="literal"><span class="pre"><a href="./back.html" class="identifier">back</a>&lt;r&gt;::type</span></tt></td>
  98. <td>The last element in <tt class="literal"><span class="pre">r</span></tt>; see
  99. <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  100. </tr>
  101. <tr><td><tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a>&lt;r,n&gt;::type</span></tt></td>
  102. <td>The <tt class="literal"><span class="pre">n</span></tt>th element from the beginning of <tt class="literal"><span class="pre">r</span></tt>; see
  103. <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </div>
  108. <div class="section" id="id92">
  109. <h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
  110. <pre class="literal-block">
  111. typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,0&gt; range0;
  112. typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,1&gt; range1;
  113. typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt; range10;
  114. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;range0&gt;::value, ==, 0 );
  115. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;range1&gt;::value, ==, 1 );
  116. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;range10&gt;::value, ==, 10 );
  117. <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./empty.html" class="identifier">empty</a>&lt;range0&gt; ));
  118. <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./empty.html" class="identifier">empty</a>&lt;range1&gt; ));
  119. <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./empty.html" class="identifier">empty</a>&lt;range10&gt; ));
  120. <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./begin.html" class="identifier">begin</a>&lt;range0&gt;::type, <a href="./end.html" class="identifier">end</a>&lt;range0&gt;::type &gt; ));
  121. <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( is_same&lt; <a href="./begin.html" class="identifier">begin</a>&lt;range1&gt;::type, <a href="./end.html" class="identifier">end</a>&lt;range1&gt;::type &gt; ));
  122. <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( is_same&lt; <a href="./begin.html" class="identifier">begin</a>&lt;range10&gt;::type, <a href="./end.html" class="identifier">end</a>&lt;range10&gt;::type &gt; ));
  123. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./front.html" class="identifier">front</a>&lt;range1&gt;::type::value, ==, 0 );
  124. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./back.html" class="identifier">back</a>&lt;range1&gt;::type::value, ==, 0 );
  125. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./front.html" class="identifier">front</a>&lt;range10&gt;::type::value, ==, 0 );
  126. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./back.html" class="identifier">back</a>&lt;range10&gt;::type::value, ==, 9 );
  127. </pre>
  128. </div>
  129. <div class="section" id="id93">
  130. <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
  131. <p><a class="reference internal" href="./sequences.html">Sequences</a>, <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>, <a class="reference internal" href="./vector-c.html">vector_c</a>, <a class="reference internal" href="./set-c.html">set_c</a>, <a class="reference internal" href="./list-c.html">list_c</a></p>
  132. <!-- Sequences/Classes//vector_c |70 -->
  133. </div>
  134. </div>
  135. <div class="footer-separator"></div>
  136. <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./map.html" class="navigation-link">Prev</a>&nbsp;<a href="./vector-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./map.html" class="navigation-link">Back</a>&nbsp;<a href="./vector-c.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./classes.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  137. <td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
  138. Distributed under the Boost Software License, Version 1.0. (See accompanying
  139. file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
  140. </html>