mirror of
https://github.com/boostorg/preprocessor.git
synced 2026-01-22 05:22:35 +00:00
161 lines
5.4 KiB
HTML
161 lines
5.4 KiB
HTML
<a href="../index.htm"><IMG height=86
|
|
alt="c++boost.gif (8819 bytes)"
|
|
src="../../../../c++boost.gif"
|
|
width=277 align=center></a>
|
|
<hr>
|
|
<!-- Generated by Doxygen -->
|
|
<center>
|
|
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="globals.html">File Members</a> </center>
|
|
<hr><h1>repeat.hpp File Reference</h1><a href="../../../../boost/preprocessor/repeat.hpp">Click here to see the header.</a>.
|
|
<a href="#_details">More...</a>
|
|
<p>
|
|
<table border=0 cellpadding=0 cellspacing=0>
|
|
<tr><td colspan=2><br><h2>Defines</h2></td></tr>
|
|
<tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="repeat_8hpp.html#a0">BOOST_PP_REPEAT</a>(N, M, P)</td></tr>
|
|
<tr><td> </td><td><font size=-1><em>Repeats the macro M(I,P) for I = 0 to N-1.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr>
|
|
<tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="repeat_8hpp.html#a1">BOOST_PREPROCESSOR_REPEAT</a>(N, M, P)</td></tr>
|
|
<tr><td> </td><td><font size=-1><em>Obsolete.</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr>
|
|
</table>
|
|
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
|
<a href="../../../../boost/preprocessor/repeat.hpp">Click here to see the header.</a>.
|
|
<p>
|
|
|
|
<p>
|
|
<hr><h2>Define Documentation</h2>
|
|
<a name="a0" doxytag="repeat.hpp::BOOST_PP_REPEAT"></a><p>
|
|
<table width="100%" cellpadding="2" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> #define BOOST_PP_REPEAT</td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">N, <tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="md" nowrap>M, <tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="md" nowrap>P </td>
|
|
<td class="mdname1" valign="top" nowrap> </td>
|
|
<td class="md" valign="top">) </td>
|
|
<td class="md" nowrap>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
<td>
|
|
|
|
<p>
|
|
Repeats the macro M(I,P) for I = 0 to N-1.
|
|
<p>
|
|
In other words, expands to the sequence:
|
|
<p>
|
|
<pre><div class="fragment"><pre>
|
|
M(0,P) M(1,P) ... M(N-1,P)
|
|
</pre></div></pre>
|
|
<p>
|
|
See BOOST_PP_LIMIT_MAG.
|
|
<p>
|
|
<h3>2D and 3D repetition</h3>
|
|
|
|
<p>
|
|
2D and 3D repetition are supported with the <a class="el" href="repeat__2nd_8hpp.html#a0">BOOST_PP_REPEAT_2ND</a>() and <a class="el" href="repeat__3rd_8hpp.html#a0">BOOST_PP_REPEAT_3RD</a>() macros. For example,
|
|
<p>
|
|
<pre><div class="fragment"><pre>
|
|
A generalized macro for generating 2D arrays
|
|
#define ARRAY_2D(W,H,M,P)\
|
|
BOOST_PP_REPEAT_2ND\
|
|
( H\
|
|
, ARRAY_2D_ROW\
|
|
, (W,H,M,P)\
|
|
)
|
|
#define ARRAY_2D_ROW(Y,WHMP)\
|
|
BOOST_PP_EXPAND\
|
|
( BOOST_PP_REPEAT\
|
|
( BOOST_PP_TUPLE_ELEM(4,0,WHMP)\
|
|
, ARRAY_2D_ELEM\
|
|
, (Y,BOOST_PP_TUPLE4_ENUM WHMP)\
|
|
)\
|
|
)
|
|
#define BOOST_PP_TUPLE4_ENUM(A,B,C,D) A,B,C,D
|
|
#define ARRAY_2D_ELEM(X,YWHMP)\
|
|
BOOST_PP_TUPLE_ELEM(5,3,YWHMP)\
|
|
BOOST_PP_EXPAND\
|
|
( ( X\
|
|
, BOOST_PP_TUPLE_ELEM(5,0,YWHMP)\
|
|
, BOOST_PP_TUPLE_ELEM(5,1,YWHMP)\
|
|
, BOOST_PP_TUPLE_ELEM(5,2,YWHMP)\
|
|
, BOOST_PP_TUPLE_ELEM(5,4,YWHMP)\
|
|
)\
|
|
)
|
|
|
|
Here we use the above macro to generate something
|
|
#define ELEM(X,Y,W,H,E) BOOST_PP_COMMA_IF(BOOST_PP_OR(X,Y)) E##_##X##_##Y
|
|
|
|
ARRAY_2D(3,4,ELEM,elem)
|
|
</pre></div></pre>
|
|
<p>
|
|
expands to:
|
|
<p>
|
|
<pre><div class="fragment"><pre>
|
|
elem_0_0, elem_1_0, elem_2_0,
|
|
elem_0_1, elem_1_1, elem_2_1,
|
|
elem_0_2, elem_1_2, elem_2_2,
|
|
elem_0_3, elem_1_3, elem_2_3
|
|
</pre></div></pre>
|
|
<p>
|
|
Since recursive expansion of macros is not allowed by the C++ preprocessor, replacing the BOOST_PP_REPEAT_2ND above with BOOST_PP_REPEAT, would not produce the above expansion.
|
|
<p>
|
|
See <a class="el" href="for_8hpp.html#a0">BOOST_PP_FOR</a>(). </td>
|
|
</tr>
|
|
</table>
|
|
<a name="a1" doxytag="repeat.hpp::BOOST_PREPROCESSOR_REPEAT"></a><p>
|
|
<table width="100%" cellpadding="2" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top"> #define BOOST_PREPROCESSOR_REPEAT</td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">N, <tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="md" nowrap>M, <tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="md" nowrap>P </td>
|
|
<td class="mdname1" valign="top" nowrap> </td>
|
|
<td class="md" valign="top">) </td>
|
|
<td class="md" nowrap>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing=5 cellpadding=0 border=0>
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
<td>
|
|
|
|
<p>
|
|
Obsolete.
|
|
<p>
|
|
Use <a class="el" href="repeat_8hpp.html#a0">BOOST_PP_REPEAT</a>(). </td>
|
|
</tr>
|
|
</table>
|
|
<hr>
|
|
<p>© Copyright Housemarque Oy 2001</p>
|
|
<p>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. </p>
|
|
|
|
<p>Generated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
|