Added FROM_TO repetition macros.

[SVN r13364]
This commit is contained in:
Vesa Karvonen
2002-04-04 08:23:26 +00:00
parent acb748ed77
commit 3468956bc9
14 changed files with 290 additions and 9 deletions

View File

@ -93,6 +93,9 @@ BOOST_PP_OR
BOOST_PP_REPEAT
BOOST_PP_REPEAT_2ND
BOOST_PP_REPEAT_3RD
BOOST_PP_REPEAT_FROM_TO
BOOST_PP_REPEAT_FROM_TO_2ND
BOOST_PP_REPEAT_FROM_TO_3RD
BOOST_PP_STRINGIZE
BOOST_PP_SUB
BOOST_PP_SUB_D

View File

@ -116,6 +116,9 @@
<dt><a href="repeat.htm#BOOST_PP_REPEAT">BOOST_PP_REPEAT</a></dt>
<dt><a href="repeat_2nd.htm#BOOST_PP_REPEAT_2ND">BOOST_PP_REPEAT_2ND</a></dt>
<dt><a href="repeat_3rd.htm#BOOST_PP_REPEAT_3RD">BOOST_PP_REPEAT_3RD</a></dt>
<dt><a href="repeat_from_to.htm#BOOST_PP_REPEAT_FROM_TO">BOOST_PP_REPEAT_FROM_TO</a></dt>
<dt><a href="repeat_from_to_2nd.htm#BOOST_PP_REPEAT_FROM_TO_2ND">BOOST_PP_REPEAT_FROM_TO_2ND</a></dt>
<dt><a href="repeat_from_to_3rd.htm#BOOST_PP_REPEAT_FROM_TO_3RD">BOOST_PP_REPEAT_FROM_TO_3RD</a></dt>
<dt><a href="stringize.htm#BOOST_PP_STRINGIZE">BOOST_PP_STRINGIZE</a></dt>
<dt><a href="arithmetic_sub.htm#BOOST_PP_SUB">BOOST_PP_SUB</a></dt>
<dt><a href="arithmetic_sub.htm#BOOST_PP_SUB_D">BOOST_PP_SUB_D</a></dt>
@ -235,6 +238,9 @@
<dt>#include &lt;<a href="repeat.htm">boost/preprocessor/repeat.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="repeat_2nd.htm">boost/preprocessor/repeat_2nd.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="repeat_3rd.htm">boost/preprocessor/repeat_3rd.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="repeat_from_to.htm">boost/preprocessor/repeat_from_to.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="repeat_from_to_2nd.htm">boost/preprocessor/repeat_from_to_2nd.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="repeat_from_to_3rd.htm">boost/preprocessor/repeat_from_to_3rd.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="stringize.htm">boost/preprocessor/stringize.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="tuple.htm">boost/preprocessor/tuple.hpp</a>&gt;</dt>
<dt>#include &lt;<a href="tuple_eat.htm">boost/preprocessor/tuple/eat.hpp</a>&gt;</dt>

View File

@ -27,7 +27,7 @@
<hr>
<h2><a name="BOOST_PP_REPEAT">#define BOOST_PP_REPEAT</a>(N,M,P)</h2>
<p>Repeats the macro <code>M(I,P)</code> for I = [0,N[.</p>
<p>Repeats the macro <code>M(I,P)</code> for <code>I = [0,N[</code>.</p>
<p>In other words, expands to the sequence:</p>

View File

@ -19,7 +19,7 @@
<hr>
<a href="repeat_2nd.htm">Prev</a> <a href="stringize.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<a href="repeat_2nd.htm">Prev</a> <a href="repeat_from_to.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/repeat_3rd.hpp">boost/preprocessor/repeat_3rd.hpp</a>&gt;</h1>
@ -34,7 +34,7 @@
<p>Obsolete. Use <a href="repeat_3rd.htm#BOOST_PP_REPEAT_3RD">BOOST_PP_REPEAT_3RD</a>().</p>
<hr>
<a href="repeat_2nd.htm">Prev</a> <a href="stringize.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<a href="repeat_2nd.htm">Prev</a> <a href="repeat_from_to.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>

View File

@ -0,0 +1,75 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor - Reference</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="repeat_3rd.htm">Prev</a> <a href="repeat_from_to_2nd.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/repeat_from_to.hpp">boost/preprocessor/repeat_from_to.hpp</a>&gt;</h1>
<hr>
<h2><a name="BOOST_PP_REPEAT_FROM_TO">#define BOOST_PP_REPEAT_FROM_TO</a>(S,E,M,P)</h2>
<p>Repeats the macro <code>M(I,P)</code> for <code>I = [S,E[</code>.</p>
<p>In other words, expands to the sequence:</p>
<pre>
M(S,P) M(<a href="inc.htm#BOOST_PP_INC">BOOST_PP_INC</a>(S),P) ... M(<a href="dec.htm#BOOST_PP_DEC">BOOST_PP_DEC</a>(E),P)
</pre>
<p>For example,</p>
<pre>
#define TEST(I,P) P(I);
<a href="repeat_from_to.htm#BOOST_PP_REPEAT_FROM_TO">BOOST_PP_REPEAT_FROM_TO</a>(4,7,TEST,X)
</pre>
<p>expands to:</p>
<pre>
X(4); X(5); X(6);
</pre>
<h3>Uses</h3>
<ul>
<li><a href="repeat.htm#BOOST_PP_REPEAT">BOOST_PP_REPEAT</a>()</li>
</ul>
<h3>Test</h3>
<ul>
<li><a href="../../test/repeat_test.cpp">repeat_test.cpp</a></li>
</ul>
<hr>
<a href="repeat_3rd.htm">Prev</a> <a href="repeat_from_to_2nd.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>

View File

@ -0,0 +1,45 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor - Reference</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="repeat_from_to.htm">Prev</a> <a href="repeat_from_to_3rd.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/repeat_from_to_2nd.hpp">boost/preprocessor/repeat_from_to_2nd.hpp</a>&gt;</h1>
<hr>
<h2><a name="BOOST_PP_REPEAT_FROM_TO_2ND">#define BOOST_PP_REPEAT_FROM_TO_2ND</a>(S,E,M,P)</h2>
<p>Same as <a href="repeat_from_to.htm#BOOST_PP_REPEAT_FROM_TO">BOOST_PP_REPEAT_FROM_TO</a>(), but implemented independently.</p>
<hr>
<a href="repeat_from_to.htm">Prev</a> <a href="repeat_from_to_3rd.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>

View File

@ -0,0 +1,45 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost.Preprocessor - Reference</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="repeat_from_to_2nd.htm">Prev</a> <a href="stringize.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/repeat_from_to_3rd.hpp">boost/preprocessor/repeat_from_to_3rd.hpp</a>&gt;</h1>
<hr>
<h2><a name="BOOST_PP_REPEAT_FROM_TO_3RD">#define BOOST_PP_REPEAT_FROM_TO_3RD</a>(S,E,M,P)</h2>
<p>Same as <a href="repeat_from_to.htm#BOOST_PP_REPEAT_FROM_TO">BOOST_PP_REPEAT_FROM_TO</a>(), but implemented independently.</p>
<hr>
<a href="repeat_from_to_2nd.htm">Prev</a> <a href="stringize.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>

View File

@ -19,7 +19,7 @@
<hr>
<a href="repeat_3rd.htm">Prev</a> <a href="tuple.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<a href="repeat_from_to_3rd.htm">Prev</a> <a href="tuple.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/stringize.hpp">boost/preprocessor/stringize.hpp</a>&gt;</h1>
@ -47,7 +47,7 @@
<p>Obsolete. Use <a href="stringize.htm#BOOST_PP_STRINGIZE">BOOST_PP_STRINGIZE</a>().</p>
<hr>
<a href="repeat_3rd.htm">Prev</a> <a href="tuple.htm">Next</a> <a href="index.htm#Macros">Macros</a> <a href="index.htm#Headers">Headers</a>
<a href="repeat_from_to_3rd.htm">Prev</a> <a href="tuple.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>

View File

@ -29,8 +29,8 @@
#include <boost/preprocessor/logical.hpp>
#include <boost/preprocessor/max.hpp>
#include <boost/preprocessor/min.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/repeat_2nd.hpp>
#include <boost/preprocessor/repeat_3rd.hpp>
#include <boost/preprocessor/repeat_from_to.hpp>
#include <boost/preprocessor/repeat_from_to_2nd.hpp>
#include <boost/preprocessor/repeat_from_to_3rd.hpp>
#include <boost/preprocessor/stringize.hpp>
#endif

View File

@ -13,7 +13,7 @@
* See http://www.boost.org for most recent version.
*/
/** <p>Repeats the macro <code>M(I,P)</code> for I = [0,N[.</p>
/** <p>Repeats the macro <code>M(I,P)</code> for <code>I = [0,N[</code>.</p>
<p>In other words, expands to the sequence:</p>

View File

@ -0,0 +1,53 @@
#ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_HPP
#define BOOST_PREPROCESSOR_REPEAT_FROM_TO_HPP
/* Copyright (C) 2002
* Housemarque Oy
* http://www.housemarque.com
*
* Permission to copy, use, modify, sell and distribute this software is
* granted provided this copyright notice appears in all copies. This
* software is provided "as is" without express or implied warranty, and
* with no claim as to its suitability for any purpose.
*
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/arithmetic/sub.hpp>
#include <boost/preprocessor/arithmetic/add.hpp>
/** <p>Repeats the macro <code>M(I,P)</code> for <code>I = [S,E[</code>.</p>
<p>In other words, expands to the sequence:</p>
<pre>
M(S,P) M(BOOST_PP_INC(S),P) ... M(BOOST_PP_DEC(E),P)
</pre>
<p>For example,</p>
<pre>
#define TEST(I,P) P(I);
BOOST_PP_REPEAT_FROM_TO(4,7,TEST,X)
</pre>
<p>expands to:</p>
<pre>
X(4); X(5); X(6);
</pre>
<h3>Uses</h3>
<ul>
<li>BOOST_PP_REPEAT()</li>
</ul>
<h3>Test</h3>
<ul>
<li><a href="../../test/repeat_test.cpp">repeat_test.cpp</a></li>
</ul>
*/
#define BOOST_PP_REPEAT_FROM_TO(S,E,M,P) BOOST_PP_REPEAT(BOOST_PP_SUB(E,S),BOOST_PP_REPEAT_FROM_TO_F,(S,M,P))
#define BOOST_PP_REPEAT_FROM_TO_F(I,SMP) BOOST_PP_TUPLE_ELEM(3,1,SMP)(BOOST_PP_ADD(I,BOOST_PP_TUPLE_ELEM(3,0,SMP)),BOOST_PP_TUPLE_ELEM(3,2,SMP))
#endif

View File

@ -0,0 +1,23 @@
#ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_2ND_HPP
#define BOOST_PREPROCESSOR_REPEAT_FROM_TO_2ND_HPP
/* Copyright (C) 2002
* Housemarque Oy
* http://www.housemarque.com
*
* Permission to copy, use, modify, sell and distribute this software is
* granted provided this copyright notice appears in all copies. This
* software is provided "as is" without express or implied warranty, and
* with no claim as to its suitability for any purpose.
*
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/repeat_2nd.hpp>
#include <boost/preprocessor/arithmetic/sub.hpp>
#include <boost/preprocessor/arithmetic/add.hpp>
/** <p>Same as BOOST_PP_REPEAT_FROM_TO(), but implemented independently.</p> */
#define BOOST_PP_REPEAT_FROM_TO_2ND(S,E,M,P) BOOST_PP_REPEAT_2ND(BOOST_PP_SUB(E,S),BOOST_PP_REPEAT_FROM_TO_2ND_F,(S,M,P))
#define BOOST_PP_REPEAT_FROM_TO_2ND_F(I,SMP) BOOST_PP_TUPLE_ELEM(3,1,SMP)(BOOST_PP_ADD(I,BOOST_PP_TUPLE_ELEM(3,0,SMP)),BOOST_PP_TUPLE_ELEM(3,2,SMP))
#endif

View File

@ -0,0 +1,23 @@
#ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_3RD_HPP
#define BOOST_PREPROCESSOR_REPEAT_FROM_TO_3RD_HPP
/* Copyright (C) 2002
* Housemarque Oy
* http://www.housemarque.com
*
* Permission to copy, use, modify, sell and distribute this software is
* granted provided this copyright notice appears in all copies. This
* software is provided "as is" without express or implied warranty, and
* with no claim as to its suitability for any purpose.
*
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/repeat_3rd.hpp>
#include <boost/preprocessor/arithmetic/sub.hpp>
#include <boost/preprocessor/arithmetic/add.hpp>
/** <p>Same as BOOST_PP_REPEAT_FROM_TO(), but implemented independently.</p> */
#define BOOST_PP_REPEAT_FROM_TO_3RD(S,E,M,P) BOOST_PP_REPEAT_3RD(BOOST_PP_SUB(E,S),BOOST_PP_REPEAT_FROM_TO_3RD_F,(S,M,P))
#define BOOST_PP_REPEAT_FROM_TO_3RD_F(I,SMP) BOOST_PP_TUPLE_ELEM(3,1,SMP)(BOOST_PP_ADD(I,BOOST_PP_TUPLE_ELEM(3,0,SMP)),BOOST_PP_TUPLE_ELEM(3,2,SMP))
#endif

View File

@ -14,6 +14,8 @@
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/enum_params_with_a_default.hpp>
#include <boost/preprocessor/enum_params_with_defaults.hpp>
#include <boost/preprocessor/repeat_from_to.hpp>
#include <libs/preprocessor/test/test.hpp>
/* *** */
@ -46,3 +48,9 @@ TEST_ENUM_PARAMS(ENUM_PARAMS_TEST_MAX)
template<BOOST_PP_ENUM_PARAMS(ENUM_PARAMS_TEST_MAX,class T)>
struct no_rescan;
/* *** */
#define F(I,P) P I
TEST_B 1 + (4+5+6) BOOST_PP_REPEAT_FROM_TO(4,7,F,-) TEST_E
#undef F