The BOOST_PP_LIST_FOR_EACH_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_R(r, macro, data, list)

Arguments

r
The next available BOOST_PP_FOR repetition.
macro
A ternary macro of the form macro(r, data, elem).  This macro is expanded by BOOST_PP_LIST_FOR_EACH with each element in list.  It is expanded with the next available BOOST_PP_FOR repetition, the auxiliary data, 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, a) macro(r, data, b) macro(r, data, c)

See Also

Requirements

Header:  <boost/preprocessor/list/for_each.hpp>

Sample Code

#include <boost/preprocessor/list/adt.hpp>
#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/repetition/for.hpp>

#define LIST (x, (y, (z, BOOST_PP_NIL)))

#define MACRO_2(r, data, elem) elem

#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_R(r, MACRO_2, _, state) ]

BOOST_PP_FOR(LIST, PRED, OP, MACRO)
   // expands to [x y z] [y z] [z]

Copyright Housemarque Oy 2002
Copyright Paul Mensonides 2002

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)