Brian Silverman | f27e085 | 2018-08-04 23:56:45 -0700 | [diff] [blame^] | 1 | <html> |
| 2 | <head> |
| 3 | <meta content="text/html; charset=windows-1252" http-equiv="content-type"> |
| 4 | <title>BOOST_PP_REPEAT_z</title> |
| 5 | <link rel="stylesheet" type="text/css" href="../styles.css"> |
| 6 | </head> |
| 7 | <body> |
| 8 | <div style="margin-left: 0px;"> The <b>BOOST_PP_REPEAT_<i>z</i></b> macro |
| 9 | represents a reentry into the <b>BOOST_PP_REPEAT</b> repetition |
| 10 | construct. </div> |
| 11 | <h4>Usage</h4> |
| 12 | <div class="code"> <b>BOOST_PP_REPEAT_</b> ## <i>z</i>(<i>count</i>, <i>macro</i>, |
| 13 | <i>data</i>) </div> |
| 14 | <h4>Arguments</h4> |
| 15 | <dl> |
| 16 | <dt>z</dt> |
| 17 | <dd> The next available <b>BOOST_PP_REPEAT</b> dimension. </dd> |
| 18 | <dt>count</dt> |
| 19 | <dd> The number of repetitious calls to <i>macro</i>. Valid values |
| 20 | range from <i>0</i> to <b>BOOST_PP_LIMIT_REPEAT</b>. </dd> |
| 21 | <dt>macro</dt> |
| 22 | <dd> A ternary operation of the form <i>macro</i>(<i>z</i>, <i>n</i>, <i>data</i>). |
| 23 | This macro is expanded by <b>BOOST_PP_REPEAT</b> with the next |
| 24 | available repetition depth, the current repetition number, and the |
| 25 | auxiliary <i>data</i> argument. </dd> |
| 26 | <dt>data</dt> |
| 27 | <dd> Auxiliary data passed to <i>macro</i>. </dd> |
| 28 | </dl> |
| 29 | <h4>Remarks</h4> |
| 30 | <div> This macro expands to the sequence: |
| 31 | <div> <i>macro</i>(<i>z</i>, <i>0</i>, <i>data</i>) <i>macro</i>(<i>z</i>, |
| 32 | <i>1</i>, <i>data</i>) ... <i>macro</i>(<i>z</i>, <i>count</i> - <i>1</i>, |
| 33 | <i>data</i>) </div> |
| 34 | </div> |
| 35 | <div> At certain times, it may be necessary to perform the concatenation |
| 36 | with <b>BOOST_PP_CAT</b> rather than the preprocessor token-pasting |
| 37 | operator. This happens when the <i>z</i> value is a macro |
| 38 | invocation itself. It needs a delay to allow it to expand. The |
| 39 | syntax in such a scenario becomes: |
| 40 | <div> <b>BOOST_PP_CAT</b>(<b>BOOST_PP_REPEAT_</b>, <i>z</i>)(<i>count</i>, |
| 41 | <i>macro</i>, <i>data</i>) </div> |
| 42 | </div> |
| 43 | <h4>See Also</h4> |
| 44 | <ul> |
| 45 | <li><a href="cat.html">BOOST_PP_CAT</a></li> |
| 46 | <li><a href="limit_repeat.html">BOOST_PP_LIMIT_REPEAT</a></li> |
| 47 | <li><a href="repeat.html">BOOST_PP_REPEAT</a></li> |
| 48 | <li><a href="repeat_z_macros.html"><span style="color: gray;">Macros with |
| 49 | Z re-entrancy forms</span></a></li> |
| 50 | </ul> |
| 51 | <h4>Requirements</h4> |
| 52 | <div> <b>Header:</b> <a href="../headers/repetition/repeat.html"><boost/preprocessor/repetition/repeat.hpp></a> |
| 53 | </div> |
| 54 | <h4>Sample Code</h4> |
| 55 | <div> |
| 56 | <pre>#include <<a href="../headers/arithmetic/inc.html">boost/preprocessor/arithmetic/inc.hpp</a>> |
| 57 | #include <<a href="../headers/punctuation/comma_if.html">boost/preprocessor/punctuation/comma_if.hpp</a>> |
| 58 | #include <<a href="../headers/repetition/repeat.html">boost/preprocessor/repetition/repeat.hpp</a>> |
| 59 | |
| 60 | #define TEXT(z, n, text) <a href="comma_if.html">BOOST_PP_COMMA_IF</a>(n) text |
| 61 | |
| 62 | #define TEMPLATE(z, n, _) \ |
| 63 | <a href="comma_if.html">BOOST_PP_COMMA_IF</a>(n) \ |
| 64 | template< \ |
| 65 | <a href="repeat_z.html">BOOST_PP_REPEAT_</a> ## z( \ |
| 66 | <a href="inc.html">BOOST_PP_INC</a>(n), \ |
| 67 | TEXT, class \ |
| 68 | ) \ |
| 69 | > class T ## n \ |
| 70 | /**/ |
| 71 | |
| 72 | <a href="repeat.html">BOOST_PP_REPEAT</a>(3, TEMPLATE, nil) |
| 73 | /* |
| 74 | expands to: |
| 75 | template<class> class T0, |
| 76 | template<class, class> class T1, |
| 77 | template<class, class, class> class T2 |
| 78 | */ |
| 79 | </pre></div> |
| 80 | <hr size="1"> |
| 81 | <div style="margin-left: 0px;"> <i>© Copyright <a href="http://www.housemarque.com" |
| 82 | target="_top">Housemarque Oy</a> 2002</i> <br> |
| 83 | <i>© Copyright Paul Mensonides 2002<br> |
| 84 | </i><i>© Copyright Edward Diener 2014</i><br> |
| 85 | </div> |
| 86 | <div style="margin-left: 0px;"> |
| 87 | <p><small>Distributed under the Boost Software License, Version 1.0. (See |
| 88 | accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> |
| 89 | or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p> |
| 90 | </div> |
| 91 | </body> |
| 92 | </html> |