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

Usage

BOOST_PP_DIV_D(d, x, y)

Arguments

d
The next available BOOST_PP_WHILE iteration. 
x
The dividend (numerator) of the operation.  Valid values range from 0 to BOOST_PP_LIMIT_MAG.
y
The divisor (denominator) of the operation.  Valid values range from 1 to BOOST_PP_LIMIT_MAG.

Remarks

If y is 0, the result is undefined.

See Also

Requirements

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

Sample Code

#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/arithmetic/div.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_DIV_D(                     \
         d,                               \
         BOOST_PP_TUPLE_ELEM(2, 1, data), \
         2                                \
      )                                   \
   )                                      \
   /**/

// halve 'x' 'n' times
#define HALVE(x, n) BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_WHILE(PRED, OP, (n, x)))

HALVE(8, 2) // expands to 2
HALVE(16, 1) // expands to 8