The BOOST_PP_LIST_FOR_EACH_I_R macro repeats a macro for each element in a list.
It reenters BOOST_PP_FOR with maximum efficiency.
Usage
BOOST_PP_LIST_FOR_EACH_I_R(r, macro, data, list)
Arguments
- r
-
The next available BOOST_PP_FOR repetition.
- macro
-
A macro of the for macro(r, data, i, elem).
This macro is expanded by BOOST_PP_LIST_FOR_EACH_I with each element in list.
It is expanded with the next available BOOST_PP_FOR repetition, the auxiliary data, the index of the current element, and the current element.
- data
-
Auxiliary data passed to macro.
- list
-
The list for which macro will be invoked on each element.
Remarks
This macro is a repetition construct.
If
list is (
a, (
b, (
c,
BOOST_PP_NIL))), it expands to the sequence:
macro(r, data, 0, a) macro(r, data, 1, b) macro(r, data, 2, c)
See Also
Requirements
Sample Code
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/list/adt.hpp>
#include <boost/preprocessor/list/for_each_i.hpp>
#include <boost/preprocessor/repetition/for.hpp>
#define LIST (x, (y, (z, BOOST_PP_NIL)))
#define MACRO_2(r, data, i, elem) BOOST_PP_CAT(elem, i)
#define PRED(r, state) BOOST_PP_LIST_IS_CONS(state)
#define OP(r, state) BOOST_PP_LIST_REST(state)
#define MACRO(r, state) [ BOOST_PP_LIST_FOR_EACH_I_R(r, MACRO_2, _, state) ]
BOOST_PP_FOR(LIST, PRED, OP, MACRO)
// expands to [x0 y1 z2] [y0 z1] [z0]