C++ Boost

Boost.Preprocessor

Reference


Prev Next Macros Headers

#include <boost/preprocessor/for.hpp>


#define BOOST_PP_FOR(X,C,F,I)

Repeats I(R,X) and iterates F(R,X) while C(R,X) is true.

In other words, expands to the sequence:

  I(R,X)  I(R,F(R,X))  I(R,F(R,F(R,X)))  ...  I(R,F(R,F(...F(R,X)...)))

The length of the sequence is determined by C(R,X).

Legend

BOOST_PP_REPEAT() vs BOOST_PP_FOR()

BOOST_PP_FOR() is a generalization of BOOST_PP_REPEAT(). This means that BOOST_PP_REPEAT() can be implemented using BOOST_PP_FOR(). However, BOOST_PP_REPEAT() was introduced earlier, is generally easier to use, and is still quite useful on its own.

2D and 3D repetition

BOOST_PP_FOR() can be used for multidimensional repetition simply by invoking BOOST_PP_FOR##R() directly.

Test


Prev Next Macros Headers

Revised

© Copyright Housemarque Oy 2002

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.