Files
preprocessor/doc/reference/while.htm
Vesa Karvonen 6f18b29f39 Removed broken stylesheet link
[SVN r12700]
2002-02-04 19:42:54 +00:00

88 lines
3.5 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor</title>
</head>
<body bgcolor="#FFFFFF" link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Preprocessor</h1>
<h2 align="center">Reference</h2>
</td>
</tr>
</table>
<hr>
<a href="tuple_to_list.htm">Prev</a> <a href="arithmetic.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<hr>
<h1>#include &lt;<a href="../../../../boost/preprocessor/while.hpp">boost/preprocessor/while.hpp</a>&gt;</h1>
<hr>
<h2><a name="BOOST_PP_WHILE">#define BOOST_PP_WHILE</a>(C,F,X)</h2>
<p>Iterates <code>F(D,X)</code> while <code>C(D,X)</code> is true.</p>
<p>In other words, expands to:</p>
<pre>
F(D, ... F(D, F(D,X) ) ... )
</pre>
<p>The depth of iteration is determined by <code>C(D,X)</code>.</p>
<h3>Legend</h3>
<ul>
<li><b>X</b> is the current state of iteration. The state is usually a tuple.</li>
<li><b>C</b> is the condition for iteration. It must expand to a decimal
integer literal.</li>
<li><b>F</b> is the iterated macro. Note that if the state is a tuple, then
F(D,X) usually expands to a tuple of the same number of elements.</li>
<li><b>D</b> is the recursion depth and should only be used as a parameter
to other macros using <a href="while.htm#BOOST_PP_WHILE">BOOST_PP_WHILE</a>(). Such macros include
<a href="arithmetic_add.htm#BOOST_PP_ADD">BOOST_PP_ADD</a>() and other arithmetic operations. For each macro using
<a href="while.htm#BOOST_PP_WHILE">BOOST_PP_WHILE</a>(), there is a version of the macro, distinguished by the
D suffix (e.g. BOOST_PP_ADD_D()), that accepts an additional recursion
depth as the first parameter. This technique is necessary to avoid
recursively expanding the same macro again, which is not permitted by the
C++ preprocessor.</li>
</ul>
<h3>Note</h3>
<ul>
<li>The value of the D parameter may exceed <a href="limits.htm#BOOST_PP_LIMIT_MAG">BOOST_PP_LIMIT_MAG</a>.</li>
<li>Using <a href="while.htm#BOOST_PP_WHILE">BOOST_PP_WHILE</a>() is a bit tricky. This is due to the C++
preprocessor limitations. It is recommended to take a look at the
implementations of the various PREPROCESSOR library primitives such as
<a href="arithmetic_add.htm#BOOST_PP_ADD">BOOST_PP_ADD</a>() for additional examples.</li>
</ul>
<h3>Example</h3>
<ul>
<li><a href="../../example/count_down.c">count_down.c</a></li>
<li><a href="../../example/linear_fib.c">linear_fib.c</a></li>
<li><a href="../../example/delay.c">delay.c</a></li>
</ul>
<hr>
<a href="tuple_to_list.htm">Prev</a> <a href="arithmetic.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
<p><i>&copy; Copyright <a href="http://www.housemarque.com">Housemarque Oy</a> 2002</i></p>
<p><i>Permission to copy, use, modify, sell and distribute this document is granted
provided this copyright notice appears in all copies. This document is provided
"as is" without express or implied warranty, and with no claim as to its suitability
for any purpose.</i></p>
</body></html>