Defines | |
#define | BOOST_PP_WHILE(C, F, X) |
Iterates F(D,X) while C(D,X) is true. More... |
|
Iterates F(D,X) while C(D,X) is true.
LegendX is the current state of iteration. The state is usually a tuple. C is the condition for iteration. It must expand to a decimal integer literal. F is the iterated macro. Note that if the state is a tuple, then F(D,X) usually expands to a tuple of the same number of elements. D is the recursion depth and should only be used as a parameter to other macros implemented using BOOST_PP_WHILE(). Such macros include BOOST_PP_ADD() and other arithmetic operations. For each macro implemented using BOOST_PP_WHILE(), there is a version of the macro, distinguished by the _D suffix (e.g. BOOST_PP_ADD_D()), that accepts an additional recursion depth as the first parameter. This technique is necessary to avoid recursively expanding the same macro again, which is not permitted by the C++ preprocessor. NOTE: The value of the D parameter may exceed BOOST_PP_LIMIT_MAG.
UsageUsing BOOST_PP_WHILE() is a bit tricky. This is due to the C++ preprocessor limitations. It is recommended to take a look at the implementations of the various PREPROCESSOR library primitives such as BOOST_PP_ADD() for additional examples. Here is a trivial example that simply counts down from N to 0 ultimately expanding to a 0:
For a more complex example, let's take a look at an implementation of BOOST_PP_MUL().
ImplementationRATIONALE:
|
© Copyright Housemarque Oy 2001
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
Generated: