3 <meta content=
"text/html; charset=windows-1252" http-equiv=
"content-type">
4 <title>BOOST_PP_FOR_r
</title>
5 <link rel=
"stylesheet" type=
"text/css" href=
"../styles.css">
8 <div style=
"margin-left: 0px;"> The
<b>BOOST_PP_FOR_
<i>r
</i></b> macro
9 represents a reentry into the
<b>BOOST_PP_FOR
</b> repetition construct.
</div>
11 <div class=
"code"> <b>BOOST_PP_FOR_
</b> ##
<i>r
</i>(
<i>state
</i>,
<i>pred
</i>,
12 <i>op
</i>,
<i>macro
</i>)
</div>
16 <dd> The next available
<b>BOOST_PP_FOR
</b> repetition.
</dd>
18 <dd> The initial state.
</dd>
20 <dd> A binary predicate of the form
<i>pred
</i>(
<i>r
</i>,
<i>state
</i>).
21 This macro must expand to an integer in the range of
<i>0</i> to
<b>BOOST_PP_LIMIT_MAG
</b>.
22 <b>BOOST_PP_FOR
</b> repeatedly expands
<i>macro
</i> while this
23 predicate returns non-zero.
This macro is called with the next
24 available
<b>BOOST_PP_FOR
</b> repetition and the current
<i>state
</i>.
27 <dd> A binary operation of the form
<i>op
</i>(
<i>r
</i>,
<i>state
</i>).
28 This operation is expanded by
<b>BOOST_PP_FOR
</b> with the next
29 available
<b>BOOST_PP_FOR
</b> repetition and the current
<i>state
</i>.
30 This macro is repeatedly applied to the
<i>state
</i>, each time
31 producing a new
<i>state
</i>, until
<i>pred
</i> returns
<i>0</i>.
</dd>
33 <dd> A binary macro of the form
<i>macro
</i>(
<i>r
</i>,
<i>state
</i>).
34 This macro is expanded by
<b>BOOST_PP_FOR
</b> with the next available
<b>BOOST_PP_FOR
</b>
35 repetition and the current
<i>state
</i>.
This macro is is
36 repeated by
<b>BOOST_PP_FOR
</b> until
<i>pred
</i> returns
<i>0</i>.
</dd>
39 <div> This macro expands to the sequence:
40 <div> <i>macro
</i>(
<i>r
</i>,
<i>state
</i>)
<i>macro
</i>(
<i>r
</i>,
<i>op
</i>(
<i>r
</i>,
41 <i>state
</i>)) ...
<i>macro
</i>(
<i>r
</i>,
<i>op
</i>(
<i>r
</i>, ...
<i>op
</i>(
<i>r
</i>,
42 <i>state
</i>) ... ))
</div>
44 <div> At certain times, it may be necessary to perform the concatenation
45 with
<b>BOOST_PP_CAT
</b> rather than the preprocessor token-pasting
46 operator.
This happens when the
<i>r
</i> value is a macro
47 invocation itself.
It needs a delay to allow it to expand.
The
48 syntax in such a scenario becomes:
49 <div> <b>BOOST_PP_CAT
</b>(
<b>BOOST_PP_FOR_
</b>,
<i>r
</i>)(
<i>state
</i>,
50 <i>pred
</i>,
<i>op
</i>,
<i>macro
</i>)
</div>
54 <li><a href=
"cat.html">BOOST_PP_CAT
</a></li>
55 <li><a href=
"for.html">BOOST_PP_FOR
</a></li>
56 <li><a href=
"limit_mag.html">BOOST_PP_LIMIT_MAG
</a></li>
57 <li><a href=
"for_r_macros.html"><span style=
"color: gray;">Macros with R
58 re-entrancy forms
</span></a></li>
61 <div> <b>Header:
</b> <a href=
"../headers/repetition/for.html"><boost/preprocessor/repetition/for.hpp
></a>
65 <pre>#include
<<a href=
"../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp
</a>>
66 #include
<<a href=
"../headers/arithmetic/inc.html">boost/preprocessor/arithmetic/inc.hpp
</a>>
67 #include
<<a href=
"../headers/comparison/not_equal.html">boost/preprocessor/comparison/not_equal.hpp
</a>>
68 #include
<<a href=
"../headers/punctuation/comma_if.html">boost/preprocessor/punctuation/comma_if.hpp
</a>>
69 #include
<<a href=
"../headers/repetition/for.html">boost/preprocessor/repetition/for.hpp
</a>>
70 #include
<<a href=
"../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp
</a>>
72 #define PRED(r, state) \
73 <a href=
"not_equal.html">BOOST_PP_NOT_EQUAL
</a>( \
74 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
0, state), \
75 <a href=
"inc.html">BOOST_PP_INC
</a>( \
76 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
1, state) \
81 #define OP(r, state) \
83 <a href=
"inc.html">BOOST_PP_INC
</a>( \
84 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
0, state) \
86 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
1, state), \
87 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
2, state), \
88 <a href=
"inc.html">BOOST_PP_INC
</a>( \
89 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
3, state) \
94 #define MACRO(r, state) \
95 <a href=
"comma_if.html">BOOST_PP_COMMA_IF
</a>( \
96 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
3, state) \
98 <a href=
"for_r.html">BOOST_PP_FOR_
</a> ## r( \
99 (
0,
<a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
0, state), _,
0), \
100 PRED_2, OP, MACRO_2 \
102 > class
<a href=
"cat.html">BOOST_PP_CAT
</a>( \
103 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
2, state), \
104 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
0, state) \
108 #define PRED_2(r, state) \
109 <a href=
"not_equal.html">BOOST_PP_NOT_EQUAL
</a>( \
110 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
0, state), \
111 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
1, state) \
115 #define MACRO_2(r, state) \
116 <a href=
"comma_if.html">BOOST_PP_COMMA_IF
</a>( \
117 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
4,
0, state) \
121 #define TEMPLATE_TEMPLATE(low, high, name) \
122 <a href=
"for.html">BOOST_PP_FOR
</a>( \
123 (low, high, name,
0), \
128 TEMPLATE_TEMPLATE(
2,
4, T)
131 template
<class, class
> class T2,
132 template
<class, class, class
> class T3,
133 template
<class, class, class, class
> class T4
137 <div style=
"margin-left: 0px;"> <i>© Copyright
<a href=
"http://www.housemarque.com"
138 target=
"_top">Housemarque Oy
</a> 2002</i> <br>
139 <i>© Copyright Paul Mensonides
2002<br>
140 </i><i>© Copyright Edward Diener
2014</i><br>
142 <div style=
"margin-left: 0px;">
143 <p><small>Distributed under the Boost Software License, Version
1.0. (See
144 accompanying file
<a href=
"../../../../LICENSE_1_0.txt">LICENSE_1_0.txt
</a>
145 or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt
</a>)
</small></p>