For the
list, (
0, (
1, (
2,
BOOST_PP_NIL))), this macro expands to:
op(d, op(d, op(d, state, 0), 1), 2)
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/list/fold_right.hpp>
#define L1 (a, (b, (c, BOOST_PP_NIL)))
#define L2 (L1, (L1, (L1, BOOST_PP_NIL)))
#define OP(d, state, x) (BOOST_PP_LIST_FOLD_RIGHT_2ND_D(d, OP_2, _, x), state)
#define OP_2(d, state, x) BOOST_PP_CAT(state, x)
BOOST_PP_LIST_FOLD_RIGHT(OP, BOOST_PP_NIL, L2)
/*
expands to:
(_cba , (_cba , (_cba , BOOST_PP_NIL)))
*/