1 #ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_HPP
2 #define BOOST_PREPROCESSOR_REPEAT_FROM_TO_HPP
6 * http://www.housemarque.com
8 * Permission to copy, use, modify, sell and distribute this software is
9 * granted provided this copyright notice appears in all copies. This
10 * software is provided "as is" without express or implied warranty, and
11 * with no claim as to its suitability for any purpose.
13 * See http://www.boost.org for most recent version.
16 #include <boost/preprocessor/repeat.hpp>
17 #include <boost/preprocessor/arithmetic/sub.hpp>
18 #include <boost/preprocessor/arithmetic/add.hpp>
20 /** <p>Repeats the macro <code>MACRO(INDEX,DATA)</code> for <code>INDEX = [FIRST,LAST)</code>.</p>
22 <p>In other words, expands to the sequence:</p>
25 MACRO(FIRST,DATA) MACRO(BOOST_PP_INC(FIRST),DATA) ... MACRO(BOOST_PP_DEC(LAST),DATA)
31 #define TEST(INDEX,DATA) DATA(INDEX);
32 BOOST_PP_REPEAT_FROM_TO(4,7,TEST,X)
43 <li>BOOST_PP_REPEAT()</li>
48 <li><a href="../../test/repeat_test.cpp">repeat_test.cpp</a></li>
51 #define BOOST_PP_REPEAT_FROM_TO(FIRST,LAST,MACRO,DATA) BOOST_PP_REPEAT(BOOST_PP_SUB(LAST,FIRST),BOOST_PP_REPEAT_FROM_TO_F,(FIRST,MACRO,DATA))
52 #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))