3 <title>BOOST_PP_ADD_D
</title>
4 <link rel=
"stylesheet" type=
"text/css" href=
"../styles.css">
7 <div style=
"margin-left: 0px;">
8 The
<b>BOOST_PP_ADD_D
</b> macro expands to the sum of its second and third arguments.
9 It reenters
<b>BOOST_PP_WHILE
</b> with maximum efficiency.
13 <b>BOOST_PP_ADD_D
</b>(
<i>d
</i>,
<i>x
</i>,
<i>y
</i>)
19 The next available
<b>BOOST_PP_WHILE
</b> iteration.
23 The first addend of the operation.
24 Valid values range from
<i>0</i> to
<b>BOOST_PP_LIMIT_MAG
</b>.
28 The second addend of the operation.
29 Valid values range from
<i>0</i> to
<b>BOOST_PP_LIMIT_MAG
</b>.
34 If the sum of
<i>x
</i> and
<i>y
</i> is greater than
<b>BOOST_PP_LIMIT_MAG
</b>, the result is saturated to
<b>BOOST_PP_LIMIT_MAG
</b>.
37 This macro is the most efficient when
<i>x
</i> is greater than or equal to
<i>y
</i>.
38 However, the efficiency gain is not worth actually comparing the two arguments prior to invocation.
39 In other words,
<i>x
</i> should be the addend that is
<i>most likely
</i> to be the largest of the two operands.
43 <li><a href=
"add.html">BOOST_PP_ADD
</a></li>
44 <li><a href=
"limit_mag.html">BOOST_PP_LIMIT_MAG
</a></li>
48 <b>Header:
</b> <a href=
"../headers/arithmetic/add.html"><boost/preprocessor/arithmetic/add.hpp
></a>
52 #include
<<a href=
"../headers/arithmetic/add.html">boost/preprocessor/arithmetic/add.hpp
</a>>
53 #include
<<a href=
"../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp
</a>>
54 #include
<<a href=
"../headers/control/while.html">boost/preprocessor/control/while.hpp
</a>>
55 #include
<<a href=
"../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp
</a>>
57 #define PRED(d, data)
<a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
2,
0, data)
61 <a href=
"dec.html">BOOST_PP_DEC
</a>( \
62 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
2,
0, data) \
64 <a href=
"add_d.html">BOOST_PP_ADD_D
</a>( \
66 <a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
2,
1, data), \
72 // increment 'x' by
2 'n' times
73 #define STRIDE(x, n)
<a href=
"tuple_elem.html">BOOST_PP_TUPLE_ELEM
</a>(
2,
1,
<a href=
"while.html">BOOST_PP_WHILE
</a>(PRED, OP, (n, x)))
75 STRIDE(
10,
2) // expands to
14
76 STRIDE(
51,
6) // expands to
63
79 <div style=
"margin-left: 0px;">
80 <i>© Copyright
<a href=
"http://www.housemarque.com" target=
"_top">Housemarque Oy
</a> 2002</i>
81 </br><i>© Copyright Paul Mensonides
2002</i>
83 <div style=
"margin-left: 0px;">
84 <p><small>Distributed under the Boost Software License, Version
1.0. (See
85 accompanying file
<a href=
"../../../../LICENSE_1_0.txt">LICENSE_1_0.txt
</a> or
87 "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt
</a>)
</small></p>