]> git.lyx.org Git - lyx.git/blob - boost/boost/preprocessor/repeat_from_to.hpp
Jrgen's "Tooltips for the reference dialog" patch. I've tried to incorporate
[lyx.git] / boost / boost / preprocessor / repeat_from_to.hpp
1 #ifndef BOOST_PREPROCESSOR_REPEAT_FROM_TO_HPP
2 #define BOOST_PREPROCESSOR_REPEAT_FROM_TO_HPP
3
4 /* Copyright (C) 2002
5  * Housemarque Oy
6  * http://www.housemarque.com
7  *
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.
12  *
13  * See http://www.boost.org for most recent version.
14  */
15
16 #include <boost/preprocessor/repeat.hpp>
17 #include <boost/preprocessor/arithmetic/sub.hpp>
18 #include <boost/preprocessor/arithmetic/add.hpp>
19
20 /** <p>Repeats the macro <code>MACRO(INDEX,DATA)</code> for <code>INDEX = [FIRST,LAST)</code>.</p>
21
22 <p>In other words, expands to the sequence:</p>
23
24 <pre>
25 MACRO(FIRST,DATA) MACRO(BOOST_PP_INC(FIRST),DATA) ... MACRO(BOOST_PP_DEC(LAST),DATA)
26 </pre>
27
28 <p>For example,</p>
29
30 <pre>
31 #define TEST(INDEX,DATA) DATA(INDEX);
32 BOOST_PP_REPEAT_FROM_TO(4,7,TEST,X)
33 </pre>
34
35 <p>expands to:</p>
36
37 <pre>
38 X(4); X(5); X(6);
39 </pre>
40
41 <h3>Uses</h3>
42 <ul>
43   <li>BOOST_PP_REPEAT()</li>
44 </ul>
45
46 <h3>Test</h3>
47 <ul>
48   <li><a href="../../test/repeat_test.cpp">repeat_test.cpp</a></li>
49 </ul>
50 */
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))
53 #endif