3 <title>BOOST_PP_FOR_r</title>
4 <link rel="stylesheet" type="text/css" href="../styles.css">
7 <div style="margin-left: 0px;">
8 The <b>BOOST_PP_FOR_<i>r</i></b> macro represents a reentry into the <b>BOOST_PP_FOR</b> repetition construct.
12 <b>BOOST_PP_FOR_</b> ## <i>r</i>(<i>state</i>, <i>pred</i>, <i>op</i>, <i>macro</i>)
18 The next available <b>BOOST_PP_FOR</b> repetition.
26 A binary predicate of the form <i>pred</i>(<i>r</i>, <i>state</i>).
27 This macro must expand to an integer in the range of <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.
28 <b>BOOST_PP_FOR</b> repeatedly expands <i>macro</i> while this predicate returns non-zero.
29 This macro is called with the next available <b>BOOST_PP_FOR</b> repetition and the current <i>state</i>.
33 A binary operation of the form <i>op</i>(<i>r</i>, <i>state</i>).
34 This operation is expanded by <b>BOOST_PP_FOR</b> with the next available <b>BOOST_PP_FOR</b> repetition and the current <i>state</i>.
35 This macro is repeatedly applied to the <i>state</i>, each time producing a new <i>state</i>, until <i>pred</i> returns <i>0</i>.
39 A binary macro of the form <i>macro</i>(<i>r</i>, <i>state</i>).
40 This macro is expanded by <b>BOOST_PP_FOR</b> with the next available <b>BOOST_PP_FOR</b> repetition and the current <i>state</i>.
41 This macro is is repeated by <b>BOOST_PP_FOR</b> until <i>pred</i> returns <i>0</i>.
46 This macro expands to the sequence:
48 <i>macro</i>(<i>r</i>, <i>state</i>) <i>macro</i>(<i>r</i>, <i>op</i>(<i>r</i>, <i>state</i>)) ... <i>macro</i>(<i>r</i>, <i>op</i>(<i>r</i>, ... <i>op</i>(<i>r</i>, <i>state</i>) ... ))
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.
53 This happens when the <i>r</i> value is a macro invocation itself.
54 It needs a delay to allow it to expand.
55 The syntax in such a scenario becomes:
57 <b>BOOST_PP_CAT</b>(<b>BOOST_PP_FOR_</b>, <i>r</i>)(<i>state</i>, <i>pred</i>, <i>op</i>, <i>macro</i>)
62 <li><a href="cat.html">BOOST_PP_CAT</a></li>
63 <li><a href="for.html">BOOST_PP_FOR</a></li>
64 <li><a href="limit_mag.html">BOOST_PP_LIMIT_MAG</a></li>
68 <b>Header:</b> <a href="../headers/repetition/for.html"><boost/preprocessor/repetition/for.hpp></a>
72 #include <<a href="../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp</a>>
73 #include <<a href="../headers/arithmetic/inc.html">boost/preprocessor/arithmetic/inc.hpp</a>>
74 #include <<a href="../headers/comparison/not_equal.html">boost/preprocessor/comparison/not_equal.hpp</a>>
75 #include <<a href="../headers/punctuation/comma_if.html">boost/preprocessor/punctuation/comma_if.hpp</a>>
76 #include <<a href="../headers/repetition/for.html">boost/preprocessor/repetition/for.hpp</a>>
77 #include <<a href="../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp</a>>
79 #define PRED(r, state) \
80 <a href="not_equal.html">BOOST_PP_NOT_EQUAL</a>( \
81 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 0, state), \
82 <a href="inc.html">BOOST_PP_INC</a>( \
83 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 1, state) \
88 #define OP(r, state) \
90 <a href="inc.html">BOOST_PP_INC</a>( \
91 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 0, state) \
93 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 1, state), \
94 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 2, state), \
95 <a href="inc.html">BOOST_PP_INC</a>( \
96 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 3, state) \
101 #define MACRO(r, state) \
102 <a href="comma_if.html">BOOST_PP_COMMA_IF</a>( \
103 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 3, state) \
105 <a href="for_r.html">BOOST_PP_FOR_</a> ## r( \
106 (0, <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 0, state), _, 0), \
107 PRED_2, OP, MACRO_2 \
109 > class <a href="cat.html">BOOST_PP_CAT</a>( \
110 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 2, state), \
111 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 0, state) \
115 #define PRED_2(r, state) \
116 <a href="not_equal.html">BOOST_PP_NOT_EQUAL</a>( \
117 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 0, state), \
118 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 1, state) \
122 #define MACRO_2(r, state) \
123 <a href="comma_if.html">BOOST_PP_COMMA_IF</a>( \
124 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(4, 0, state) \
128 #define TEMPLATE_TEMPLATE(low, high, name) \
129 <a href="for.html">BOOST_PP_FOR</a>( \
130 (low, high, name, 0), \
135 TEMPLATE_TEMPLATE(2, 4, T)
138 template<class, class> class T2,
139 template<class, class, class> class T3,
140 template<class, class, class, class> class T4
144 <div style="margin-left: 0px;">
145 <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
146 </br><i>© Copyright Paul Mensonides 2002</i>
148 <div style="margin-left: 0px;">
149 <p><small>Distributed under the Boost Software License, Version 1.0. (See
150 accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
152 "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>