deduce_d.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <html>
  2. <head>
  3. <title>BOOST_PP_DEDUCE_D</title>
  4. <link rel="stylesheet" type="text/css" href="../styles.css">
  5. </head>
  6. <body>
  7. <div style="margin-left: 0px;">
  8. The <b>BOOST_PP_DEDUCE_D</b> macro manually deduces the state of the <b>BOOST_PP_WHILE</b> construct.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. <b>BOOST_PP_DEDUCE_D</b>()
  13. </div>
  14. <h4>Remarks</h4>
  15. <div>
  16. This macro is intended to avoid the use of <i>automatic-recursion</i> at deep expansion depths.&nbsp;
  17. <i>Automatic-recursion</i> at such depths can be inefficient on some preprocessors.&nbsp;
  18. It is not intended to be used directly with the invocation of macros with a <b>_D</b> suffix such as:
  19. <div>
  20. <b>BOOST_PP_ADD_D</b>(<b>BOOST_PP_DEDUCE_D</b>(), <i>x</i>, <i>y</i>)
  21. </div>
  22. If it is used in this context, the <b>_D</b> macro will fail.&nbsp;
  23. The <b>_D</b> macros directly concatenate to the <i>d</i> parameter that is passed to them,
  24. which would prevent <b>BOOST_PP_DEDUCE_D</b>() from expanding.&nbsp;
  25. Furthermore, it is pointless to use this macro in a situation such as this
  26. because it would already be too late to gain any efficiency.
  27. </div>
  28. <h4>See Also</h4>
  29. <ul>
  30. <li><a href="while.html">BOOST_PP_WHILE</a></li>
  31. </ul>
  32. <h4>Requirements</h4>
  33. <div>
  34. <b>Header:</b> &nbsp;<a href="../headers/control/deduce_d.html">&lt;boost/preprocessor/control/deduce_d.hpp&gt;</a>
  35. </div>
  36. <h4>Sample Code</h4>
  37. <div><pre>
  38. #include &lt;<a href="../headers/arithmetic/add.html">boost/preprocessor/arithmetic/add.hpp</a>&gt;
  39. #include &lt;<a href="../headers/arithmetic/inc.html">boost/preprocessor/arithmetic/inc.hpp</a>&gt;
  40. #include &lt;<a href="../headers/arithmetic/sub.html">boost/preprocessor/arithmetic/sub.hpp</a>&gt;
  41. #include &lt;<a href="../headers/control/deduce_d.html">boost/preprocessor/control/deduce_d.hpp</a>&gt;
  42. #include &lt;<a href="../headers/punctuation/comma_if.html">boost/preprocessor/punctuation/comma_if.hpp</a>&gt;
  43. #include &lt;<a href="../headers/repetition/repeat.html">boost/preprocessor/repetition/repeat.hpp</a>&gt;
  44. #include &lt;<a href="../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp</a>&gt;
  45. #define RANGE(first, last) \
  46. <a href="repeat.html">BOOST_PP_REPEAT</a>( \
  47. <a href="inc.html">BOOST_PP_INC</a>( \
  48. <a href="sub.html">BOOST_PP_SUB</a>(last, first) \
  49. ), \
  50. RANGE_M, \
  51. (first, <a href="deduce_d.html">BOOST_PP_DEDUCE_D</a>()) \
  52. ) \
  53. /**/
  54. #define RANGE_M(z, n, data) \
  55. RANGE_M_2( \
  56. n, \
  57. <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(2, 0, data), \
  58. <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(2, 1, data) \
  59. ) \
  60. /**/
  61. #define RANGE_M_2(n, first, d) \
  62. <a href="comma_if.html">BOOST_PP_COMMA_IF</a>(n) <a href="add_d.html">BOOST_PP_ADD_D</a>(d, n, first) \
  63. /**/
  64. RANGE(5, 10) // expands to 5, 6, 7, 8, 9, 10
  65. </pre></div>
  66. <hr size="1">
  67. <div style="margin-left: 0px;">
  68. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  69. </br><i>© Copyright Paul Mensonides 2002</i>
  70. </div>
  71. <div style="margin-left: 0px;">
  72. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  73. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  74. copy at <a href=
  75. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  76. </div>
  77. </body>
  78. </html>