]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <title>BOOST_PP_LIST_FOR_EACH_I</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_LIST_FOR_EACH_I</b> macro repeats a macro for each element in a <i>list</i>. | |
9 | </div> | |
10 | <h4>Usage</h4> | |
11 | <div class="code"> | |
12 | <b>BOOST_PP_LIST_FOR_EACH_I</b>(<i>macro</i>, <i>data</i>, <i>list</i>) | |
13 | </div> | |
14 | <h4>Arguments</h4> | |
15 | <dl> | |
16 | <dt>macro</dt> | |
17 | <dd> | |
18 | A macro of the form <i>macro</i>(<i>r</i>, <i>data</i>, <i>i</i>, <i>elem</i>). | |
19 | This macro is expanded by <b>BOOST_PP_LIST_FOR_EACH_I</b> with each element in <i>list</i>. | |
20 | It is expanded with the next available <b>BOOST_PP_FOR</b> repetition, the auxiliary <i>data</i>, the index of the current element, and the current element. | |
21 | </dd> | |
22 | <dt>data</dt> | |
23 | <dd> | |
24 | Auxiliary data passed to <i>macro</i>. | |
25 | </dd> | |
26 | <dt>list</dt> | |
27 | <dd> | |
28 | The <i>list</i> for which <i>macro</i> will be invoked on each element. | |
29 | </dd> | |
30 | </dl> | |
31 | <h4>Remarks</h4> | |
32 | <div> | |
33 | This macro is a repetition construct. | |
34 | If <i>list</i> is (<i>a</i>, (<i>b</i>, (<i>c</i>, <b>BOOST_PP_NIL</b>))), it expands to the sequence: | |
35 | <div> | |
36 | <i>macro</i>(<i>r</i>, <i>data</i>, <i>0</i>, <i>a</i>) <i>macro</i>(<i>r</i>, <i>data</i>, <i>1</i>, <i>b</i>) <i>macro</i>(<i>r</i>, <i>data</i>, <i>2</i>, <i>c</i>) | |
37 | </div> | |
38 | </div> | |
39 | <div> | |
40 | Previously, this macro could not be used inside <b>BOOST_PP_FOR</b>. | |
41 | There is no longer any such restriction. | |
42 | It is more efficient, however, to use <b>BOOST_PP_LIST_FOR_EACH_I_R</b> in such a situation. | |
43 | </div> | |
44 | <h4>See Also</h4> | |
45 | <ul> | |
46 | <li><a href="list_for_each_i_r.html">BOOST_PP_LIST_FOR_EACH_I_R</a></li> | |
47 | </ul> | |
48 | <h4>Requirements</h4> | |
49 | <div> | |
50 | <b>Header:</b> <a href="../headers/list/for_each_i.html"><boost/preprocessor/list/for_each_i.hpp></a> | |
51 | </div> | |
52 | <h4>Sample Code</h4> | |
53 | <div><pre> | |
54 | #include <<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>> | |
55 | #include <<a href="../headers/list/for_each_i.html">boost/preprocessor/list/for_each_i.hpp</a>> | |
56 | ||
57 | #define LIST (w, (x, (y, (z, <a href="nil.html">BOOST_PP_NIL</a>)))) | |
58 | ||
59 | #define MACRO(r, data, i, elem) <a href="cat.html">BOOST_PP_CAT</a>(elem, <a href="cat.html">BOOST_PP_CAT</a>(data, i)) | |
60 | ||
61 | <a href="list_for_each_i.html">BOOST_PP_LIST_FOR_EACH_I</a>(MACRO, _, LIST) // expands to w_0 x_1 y_2 z_3 | |
62 | </pre></div> | |
63 | <hr size="1"> | |
64 | <div style="margin-left: 0px;"> | |
65 |