shift-right.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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: shift_right</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="./shift-left.html" class="navigation-link">Prev</a>&nbsp;<a href="./trivial.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./shift-left.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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="./metafunctions.html" class="navigation-link">Metafunctions</a> / <a href="./bitwise-operations.html" class="navigation-link">Bitwise Operations</a> / <a href="./shift-right.html" class="navigation-link">shift_right</a></td>
  13. </tr></table><div class="header-separator"></div>
  14. <div class="section" id="shift-right">
  15. <h1><a class="toc-backref" href="./bitwise-operations.html#id1558">shift_right</a></h1>
  16. <div class="section" id="id1125">
  17. <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
  18. <pre class="literal-block">
  19. template&lt;
  20. typename T
  21. , typename Shift
  22. &gt;
  23. struct <a href="./shift-right.html" class="identifier">shift_right</a>
  24. {
  25. typedef <em>unspecified</em> type;
  26. };
  27. </pre>
  28. </div>
  29. <div class="section" id="id1126">
  30. <h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
  31. <p>Returns the result of bitwise <em>shift right</em> (<tt class="literal"><span class="pre">&gt;&gt;</span></tt>) operation on <tt class="literal"><span class="pre">T</span></tt>.</p>
  32. </div>
  33. <div class="section" id="id1127">
  34. <h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
  35. <pre class="literal-block">
  36. #include &lt;<a href="../../../../boost/mpl/shift_right.hpp" class="header">boost/mpl/shift_right.hpp</a>&gt;
  37. #include &lt;<a href="../../../../boost/mpl/bitwise.hpp" class="header">boost/mpl/bitwise.hpp</a>&gt;
  38. </pre>
  39. </div>
  40. <div class="section" id="id1128">
  41. <h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
  42. <p><a class="reference internal" href="./numeric-metafunction.html">Numeric Metafunction</a></p>
  43. </div>
  44. <div class="section" id="id1129">
  45. <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
  46. <table border="1" class="docutils table">
  47. <colgroup>
  48. <col width="21%" />
  49. <col width="42%" />
  50. <col width="37%" />
  51. </colgroup>
  52. <thead valign="bottom">
  53. <tr><th class="head">Parameter</th>
  54. <th class="head">Requirement</th>
  55. <th class="head">Description</th>
  56. </tr>
  57. </thead>
  58. <tbody valign="top">
  59. <tr><td><tt class="literal"><span class="pre">T</span></tt></td>
  60. <td><a class="reference internal" href="./integral-constant.html">Integral Constant</a></td>
  61. <td>A value to shift.</td>
  62. </tr>
  63. <tr><td><tt class="literal"><span class="pre">Shift</span></tt></td>
  64. <td>Unsigned <a class="reference internal" href="./integral-constant.html">Integral Constant</a></td>
  65. <td>A shift distance.</td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. <p>[<em>Note:</em> The requirements listed in this specification
  70. are the ones imposed by the default implementation. See <a class="reference internal" href="./numeric-metafunction.html">Numeric Metafunction</a> concept
  71. for the details on how to provide an implementation for a user-defined numeric type
  72. that does not satisfy the <a class="reference internal" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p>
  73. </div>
  74. <div class="section" id="id1130">
  75. <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
  76. <p>For arbitrary <a class="reference internal" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> and unsigned <a class="reference internal" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">shift</span></tt>:</p>
  77. <pre class="literal-block">
  78. typedef <a href="./shift-right.html" class="identifier">shift_right</a>&lt;c,shift&gt;::type r;
  79. </pre>
  80. <table class="docutils field-list" frame="void" rules="none">
  81. <col class="field-name" />
  82. <col class="field-body" />
  83. <tbody valign="top">
  84. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference internal" href="./integral-constant.html">Integral Constant</a>.</p>
  85. </td>
  86. </tr>
  87. <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
  88. <pre class="last literal-block">
  89. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;
  90. c::<a href="./value-type.html" class="identifier">value_type</a>
  91. , ( c::value &gt;&gt; shift::value )
  92. &gt; r;
  93. </pre>
  94. </td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. <!-- .......................................................................... -->
  99. <pre class="literal-block">
  100. typedef <a href="./shift-right.html" class="identifier">shift_right</a>&lt;c,shift&gt; r;
  101. </pre>
  102. <table class="docutils field-list" frame="void" rules="none">
  103. <col class="field-name" />
  104. <col class="field-body" />
  105. <tbody valign="top">
  106. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference internal" href="./integral-constant.html">Integral Constant</a>.</p>
  107. </td>
  108. </tr>
  109. <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
  110. <pre class="last literal-block">
  111. struct r : <a href="./shift-right.html" class="identifier">shift_right</a>&lt;c,shift&gt;::type {};
  112. </pre>
  113. </td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. </div>
  118. <div class="section" id="id1131">
  119. <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
  120. <p>Amortized constant time.</p>
  121. </div>
  122. <div class="section" id="id1132">
  123. <h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
  124. <pre class="literal-block">
  125. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0&gt; u0;
  126. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,1&gt; u1;
  127. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,2&gt; u2;
  128. typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,8&gt; u8;
  129. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-right.html" class="identifier">shift_right</a>&lt;u0,u0&gt;::value), ==, 0 );
  130. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-right.html" class="identifier">shift_right</a>&lt;u1,u0&gt;::value), ==, 1 );
  131. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-right.html" class="identifier">shift_right</a>&lt;u1,u1&gt;::value), ==, 0 );
  132. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-right.html" class="identifier">shift_right</a>&lt;u2,u1&gt;::value), ==, 1 );
  133. <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-right.html" class="identifier">shift_right</a>&lt;u8,u1&gt;::value), ==, 4 );
  134. </pre>
  135. </div>
  136. <div class="section" id="id1133">
  137. <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
  138. <p><a class="reference internal" href="./bitwise-operations.html">Bitwise Operations</a>, <a class="reference internal" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="reference internal" href="./numeric-cast.html">numeric_cast</a>, <a class="reference internal" href="./shift-left.html">shift_left</a>, <a class="reference internal" href="./bitand.html">bitand_</a></p>
  139. </div>
  140. </div>
  141. <div class="footer-separator"></div>
  142. <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./shift-left.html" class="navigation-link">Prev</a>&nbsp;<a href="./trivial.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./shift-left.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
  143. <td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
  144. Distributed under the Boost Software License, Version 1.0. (See accompanying
  145. 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>
  146. </html>