3 <meta content=
"text/html; charset=windows-1252" http-equiv=
"content-type">
4 <title>BOOST_PP_WHILE_d
</title>
5 <link rel=
"stylesheet" type=
"text/css" href=
"../styles.css">
8 <div style=
"margin-left: 0px;"> The
<b>BOOST_PP_WHILE_
<i>d
</i></b> macro
9 represents a reentry into the
<b>BOOST_PP_WHILE
</b> looping construct.
</div>
11 <div class=
"code"> <b>BOOST_PP_WHILE_
</b> ##
<i>d
</i>(
<i>pred
</i>,
<i>op
</i>,
16 <dd> The next available
<b>BOOST_PP_WHILE
</b> iteration.
</dd>
18 <dd> A binary predicate of the form
<i>pred
</i>(
<i>d
</i>,
<i>state
</i>).
19 This predicate is expanded by
<b>BOOST_PP_WHILE
</b> with the next
20 available iteration
<i>d
</i> and the current
<i>state
</i>.
This
21 predicate must expand to value in the range of
<i>0</i> to
<b>BOOST_PP_LIMIT_MAG
</b>.
22 The construct continues to loop until this predicate returns
<i>0</i>.
23 When this predicate returns
<i>0</i>,
<b>BOOST_PP_WHILE
</b> returns
24 the current
<i>state
</i>.
</dd>
26 <dd> A binary operation of the form
<i>op
</i>(
<i>d
</i>,
<i>state
</i>).
27 This operation is expanded by
<b>BOOST_PP_WHILE
</b> with the next
28 available iteration
<i>d
</i> and the current
<i>state
</i>.
This
29 macro is repeatedly applied to the
<i>state
</i>, each time producing a
30 new
<i>state
</i>, until
<i>pred
</i> returns
<i>0</i>.
</dd>
32 <dd> The initial state.
Often this argument is a
<i>tuple
</i>.
</dd>
35 <div> This macro iterates
<i>op
</i>(
<i>d
</i>,
<i>state
</i>) while
<i>pred
</i>(
<i>d
</i>,
36 <i>state
</i>) is non-zero.
In other words expands to:
37 <div> <i>op
</i>(
<i>d
</i>, ...
<i>op
</i>(
<i>d
</i>,
<i>op
</i>(
<i>d
</i>,
<i>state
</i>))
40 <div> At certain times, it may be necessary to perform the concatenation
41 with
<b>BOOST_PP_CAT
</b> rather than the preprocessor token-pasting
42 operator.
This happens when the
<i>d
</i> value is a macro
43 invocation itself.
It needs a delay to allow it to expand.
The
44 syntax in such a scenario becomes:
45 <div> <b>BOOST_PP_CAT
</b>(
<b>BOOST_PP_WHILE_
</b>,
<i>d
</i>)(
<i>pred
</i>,
46 <i>op
</i>,
<i>state
</i>).
</div>
48 <div> Previously, it was possible to concatenate
<i>d
</i> directly to
<b>BOOST_PP_WHILE
</b>
49 (without the trailing underscore).
This is no longer supported.
</div>
52 <li><a href=
"cat.html">BOOST_PP_CAT
</a></li>
53 <li><a href=
"limit_mag.html">BOOST_PP_LIMIT_MAG
</a></li>
54 <li><a href=
"while.html">BOOST_PP_WHILE
</a></li>
55 <li><a href=
"while_d_macros.html"><span style=
"color: gray;">Macros with D
56 re-entrancy forms
</span></a></li>
59 <div> <b>Header:
</b> <a href=
"../headers/control/while.html"><boost/preprocessor/control/while.hpp
></a>
63 <pre>#include
<<a href=
"../headers/arithmetic/add.html">boost/preprocessor/arithmetic/add.hpp
</a>>
64 #include
<<a href=
"../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp
</a>>
65 #include
<<a href=
"../headers/array/elem.html">boost/preprocessor/array/elem.hpp
</a>>
66 #include
<<a href=
"../headers/array/size.html">boost/preprocessor/array/size.hpp
</a>>
67 #include
<<a href=
"../headers/control/while.html">boost/preprocessor/control/while.hpp
</a>>
68 #include
<<a href=
"../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp
</a>>
70 #define PRED(d, data)
<a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
3,
1, data)
75 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
3,
0, data), \
76 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
3,
1, data), \
77 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
3,
2, data) \
81 #define OP_D(d, res, i, array) \
83 <a href=
"add_d.html">BOOST_PP_ADD_D
</a>( \
85 <a href=
"array_elem.html">BOOST_PP_ARRAY_ELEM
</a>(
<a href=
"dec.html">BOOST_PP_DEC
</a>(i), array)), \
86 <a href=
"dec.html">BOOST_PP_DEC
</a>(i), \
91 #define ACCUMULATE_D(d, array) \
92 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>( \
94 <a href=
"while_d.html">BOOST_PP_WHILE_
</a> ## d( \
96 (
0,
<a href=
"array_size.html">BOOST_PP_ARRAY_SIZE
</a>(array), array) \
101 #define ARRAY (
4, (
1,
2,
3,
4))
103 ACCUMULATE_D(
1, ARRAY)// expands to
10
106 <div style=
"margin-left: 0px;"> <i>© Copyright
<a href=
"http://www.housemarque.com"
107 target=
"_top">Housemarque Oy
</a> 2002</i> <br>
108 <i>© Copyright Paul Mensonides
2002<br>
109 </i><i>© Copyright Edward Diener
2014</i><br>
111 <div style=
"margin-left: 0px;">
112 <p><small>Distributed under the Boost Software License, Version
1.0. (See
113 accompanying file
<a href=
"../../../../LICENSE_1_0.txt">LICENSE_1_0.txt
</a>
114 or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt
</a>)
</small></p>