repeat_from_to_z.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <html>
  2. <head>
  3. <title>BOOST_PP_REPEAT_FROM_TO_z</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_REPEAT_FROM_TO_<i>z</i></b> macro represents a reentry into the <b>BOOST_PP_REPEAT_FROM_TO</b> repetition construct.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. <b>BOOST_PP_REPEAT_FROM_TO_</b> ## <i>z</i>(<i>first</i>, <i>last</i>, <i>macro</i>, <i>data</i>)
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>z</dt>
  17. <dd>
  18. The next available <b>BOOST_PP_REPEAT</b> dimension.
  19. </dd>
  20. <dt>first</dt>
  21. <dd>
  22. The lower bound of the repetition.&nbsp;
  23. Valid values range from <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.
  24. </dd>
  25. <dt>last</dt>
  26. <dd>
  27. The upper bound of the repetition.
  28. Valid values range from <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.
  29. </dd>
  30. <dt>macro</dt>
  31. <dd>
  32. A ternary operation of the form <i>macro</i>(<i>z</i>, <i>n</i>, <i>data</i>).&nbsp;
  33. This macro is expanded by <b>BOOST_PP_REPEAT</b> with the next available repetition depth,
  34. the current repetition number, and the auxiliary <i>data</i> argument.&nbsp;
  35. </dd>
  36. <dt>data</dt>
  37. <dd>
  38. Auxiliary data passed to <i>macro</i>.
  39. </dd>
  40. </dl>
  41. <h4>Remarks</h4>
  42. <div>
  43. This macro expands to the sequence:
  44. <div>
  45. <i>macro</i>(<i>z</i>, <i>first</i>, <i>data</i>) <i>macro</i>(<i>z</i>, <i>first</i> + <i>1</i>, <i>data</i>) ... <i>macro</i>(<i>z</i>, <i>last</i> - <i>1</i>, <i>data</i>)
  46. </div>
  47. </div>
  48. <div>
  49. The number of repetitions (i.e. <i>last</i> - <i>first</i>) must not exceed <b>BOOST_PP_LIMIT_REPEAT</b>.
  50. </div>
  51. <div>
  52. At certain times, it may be necessary to perform the concatenation with <b>BOOST_PP_CAT</b> rather than the preprocessor token-pasting operator.&nbsp;
  53. This happens when the <i>z</i> value is a macro invocation itself.&nbsp;
  54. It needs a delay to allow it to expand.&nbsp;
  55. The syntax in such a scenario becomes:
  56. <div>
  57. <b>BOOST_PP_CAT</b>(<b>BOOST_PP_REPEAT_FROM_TO_</b>, <i>z</i>)(<i>count</i>, <i>macro</i>, <i>data</i>).
  58. </div>
  59. </div>
  60. <h4>See Also</h4>
  61. <ul>
  62. <li><a href="cat.html">BOOST_PP_CAT</a></li>
  63. <li><a href="limit_repeat.html">BOOST_PP_LIMIT_REPEAT</a></li>
  64. <li><a href="repeat.html">BOOST_PP_REPEAT</a></li>
  65. </ul>
  66. <h4>Requirements</h4>
  67. <div>
  68. <b>Header:</b> &nbsp;<a href="../headers/repetition/repeat_from_to.html">&lt;boost/preprocessor/repetition/repeat_from_to.hpp&gt;</a>
  69. </div>
  70. <h4>Sample Code</h4>
  71. <div><pre>
  72. #include &lt;<a href="../headers/repetition/repeat_from_to.html">boost/preprocessor/repetition/repeat_from_to.hpp</a>&gt;
  73. #define TEXT(z, n, data) n data
  74. #define MACRO(z, n, data) \
  75. ( \
  76. <a href="repeat_from_to_z.html">BOOST_PP_REPEAT_FROM_TO_</a> ## z( \
  77. 1, 4, \
  78. TEXT, xyz \
  79. ) \
  80. ) \
  81. /**/
  82. <a href="repeat.html">BOOST_PP_REPEAT</a>(3, MACRO, _)
  83. /*
  84. expands to:
  85. (1 xyz 2 xyz 3 xyz)
  86. (1 xyz 2 xyz 3 xyz)
  87. (1 xyz 2 xyz 3 xyz)
  88. */
  89. </pre></div>
  90. <hr size="1">
  91. <div style="margin-left: 0px;">
  92. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  93. </br><i>© Copyright Paul Mensonides 2002</i>
  94. </div>
  95. <div style="margin-left: 0px;">
  96. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  97. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  98. copy at <a href=
  99. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  100. </div>
  101. </body>
  102. </html>