BOOST_PP_LIST_FOLD_RIGHT_2ND_D

The BOOST_PP_LIST_FOLD_RIGHT_2ND_D macro folds (or accumulates) the elements of a list right-to-left. It reenters BOOST_PP_WHILE with maximum efficiency.

#### Usage

BOOST_PP_LIST_FOLD_RIGHT_2ND_D(d, op, state, list)

#### Arguments

d
  The next available BOOST_PP_WHILE iteration.
op
  A ternary operation of the form op(d, state, elem). This macro is called for each element in list--each time returning a new state. This operation is expanded by BOOST_PP_LIST_FOLD_RIGHT with the next available BOOST_PP_WHILE iteration, the current state, and the current element.
state
  The initial state of the fold.
list
  The list to be folded.

#### Remarks

For the list, (0, (1, (2, BOOST_PP_NIL))), this macro expands to:
op(d, op(d, op(d, state, 0), 1), 2)
This macro has been superceded by BOOST_PP_LIST_FOLD_RIGHT_d and is deprecated. It only allows a single reentry into BOOST_PP_LIST_FOLD_RIGHT.

#### See Also

- BOOST_PP_LIST_FOLD_RIGHT
- BOOST_PP_LIST_FOLD_RIGHT_d

#### Requirements

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

#### Sample Code

    #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)))
    */

© 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)