]> git.lyx.org Git - lyx.git/blob - boost/boost/preprocessor/arithmetic/mod.hpp
268e2207104000e3c006c19e04fe29ef718a11fd
[lyx.git] / boost / boost / preprocessor / arithmetic / mod.hpp
1 #ifndef BOOST_PREPROCESSOR_ARITHMETIC_MOD_HPP
2 #define BOOST_PREPROCESSOR_ARITHMETIC_MOD_HPP
3
4 /* Copyright (C) 2001
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/comparison/less_equal.hpp>
17
18 /** <p>Expands to the remainder of <code>X</code> and <code>Y</code>.</p>
19
20 <p>Both <code>X</code> and <code>Y</code> must expand to integer literals
21 in the range [0, BOOST_PP_LIMIT_MAG].</p>
22
23 <p>For example, <code>BOOST_PP_MOD(4,3)</code> expands to <code>1</code> (a
24 single token).</p>
25
26 <h3>Test</h3>
27 <ul>
28   <li><a href="../../test/arithmetic_test.cpp">arithmetic_test.cpp</a></li>
29 </ul>
30 */
31 #define BOOST_PP_MOD(X,Y) BOOST_PP_MOD_D(0,X,Y)
32
33 /** <p>Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).</p> */
34 #define BOOST_PP_MOD_D(D,X,Y) BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_WHILE##D(BOOST_PP_MOD_C,BOOST_PP_MOD_F,(X,Y)))
35 #define BOOST_PP_MOD_C(D,RY) BOOST_PP_LESS_EQUAL_D(D,BOOST_PP_TUPLE_ELEM(2,1,RY),BOOST_PP_TUPLE_ELEM(2,0,RY))
36 #define BOOST_PP_MOD_F(D,RY) (BOOST_PP_SUB_D(D,BOOST_PP_TUPLE_ELEM(2,0,RY),BOOST_PP_TUPLE_ELEM(2,1,RY)),BOOST_PP_TUPLE_ELEM(2,1,RY))
37 #endif