The BOOST_PP_ADD_D macro expands to the sum of its second and third arguments.  It reenters BOOST_PP_WHILE with maximum efficiency.

Usage

BOOST_PP_ADD_D(d, x, y)

Arguments

d
The next available BOOST_PP_WHILE iteration. 
x
The first addend of the operation.  Valid values range from 0 to BOOST_PP_LIMIT_MAG.
y
The second addend of the operation.  Valid values range from 0 to BOOST_PP_LIMIT_MAG.

Remarks

If the sum of x and y is greater than BOOST_PP_LIMIT_MAG, the result is saturated to BOOST_PP_LIMIT_MAG.
This macro is the most efficient when x is less than or equal to y.  However, the efficiency gain is not worth actually comparing the two arguments prior to invocation.  In other words, x should be the addend that is most likely to be the largest of the two operands.

See Also

Requirements

Header:  <boost/preprocessor/arithmetic/add.hpp>

Sample Code

#include <boost/preprocessor/arithmetic/add.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/control/while.hpp>
#include <boost/preprocessor/tuple/elem.hpp>

#define PRED(d, data) BOOST_PP_TUPLE_ELEM(2, 0, data)

#define OP(d, data) /* ............... */ \
   (                                      \
      BOOST_PP_DEC(                       \
         BOOST_PP_TUPLE_ELEM(2, 0, data)  \
      ),                                  \
      BOOST_PP_ADD_D(                     \
         d,                               \
         BOOST_PP_TUPLE_ELEM(2, 1, data), \
         2                                \
      )                                   \
   )                                      \
   /**/

// increment 'x' by 2 'n' times
#define STRIDE(x, n) BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_WHILE(PRED, OP, (n, x)))

STRIDE(10, 2) // expands to 14
STRIDE(51, 6) // expands to 63