The BOOST_PP_LIST_FOLD_RIGHT macro folds (or accumulates) the elements of a list right-to-left.
Usage
BOOST_PP_LIST_FOLD_RIGHT(op, state, list)
Arguments
- 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
This macro does not have the same signature as it previously did.
The arguments have been swapped to provide a uniform interface with BOOST_PP_LIST_FOLD_LEFT.
For the
list, (
0, (
1, (
2,
BOOST_PP_NIL))), this macro expands to:
op(d, op(d, op(d, state, 2), 1), 0)
Previously, this macro could not be used inside BOOST_PP_WHILE.
There is no longer any such restriction.
It is more efficient, however, to use BOOST_PP_LIST_FOLD_RIGHT_d in such a situation.
See Also
Requirements
Sample Code