# Boost.Preprocessor - Reference

###

# Boost.Preprocessor

## Reference

Prev Next Macros Headers

# #include <boost/preprocessor/list/for_each.hpp>

## #define BOOST_PP_LIST_FOR_EACH(MACRO,DATA,LIST)

Repeats `MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,INDEX))` for each INDEX = [0, BOOST_PP_LIST_SIZE(LIST)).

In other words, expands to the sequence:

      MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,0))
      MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,1))
      ...
      MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST))))

For example,

      #define TEST(R,DATA,X) BOOST_PP_CAT(DATA,X)();
      BOOST_PP_LIST_FOR_EACH(TEST,prefix_,BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))

expands to:

      prefix_A(); prefix_B(); prefix_C();

### Example

- catch_builtin.cpp

### Uses

- BOOST_PP_FOR() (see for explanation of the R parameter)
- BOOST_PP_LIST_FOR_EACH_I()

### Test

- list_test.cpp

## #define BOOST_PP_LIST_FOR_EACH_R(R,MACRO,DATA,LIST)

Can be used inside BOOST_PP_FOR().

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.