C++ Boost

Boost.Preprocessor

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


Prev Next Macros Headers

#define BOOST_PP_LIST_FOLD_RIGHT(OP,LIST,STATE)

Iterates OP(D,X,STATE) for each element X of the list LIST (from the right or the end of the list).

In other words, expands to:

OP
( D
, BOOST_PP_LIST_AT(LIST,0)
, ... OP
      ( D
      , BOOST_PP_LIST_AT(LIST,BOOST_PP_SUB(BOOST_PP_LIST_SIZE(LIST),2))
      , OP
        ( D
        , BOOST_PP_LIST_AT(LIST,BOOST_PP_SUB(BOOST_PP_LIST_SIZE(LIST),1))
        , STATE
        )
      ) ...
)

For example,

#define TEST(D,X,STATE) BOOST_PP_CAT(STATE,X)
BOOST_PP_LIST_FOLD_RIGHT(TEST,_,BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))

expands to:

_CBA

Note

Test


#define BOOST_PP_LIST_FOLD_RIGHT_D(D,OP,LIST,STATE)

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

Note


#define BOOST_PP_LIST_FOLD_RIGHT_2ND

Obsolete, just use BOOST_PP_LIST_FOLD_RIGHT().


#define BOOST_PP_LIST_FOLD_RIGHT_2ND_D

Obsolete, just use BOOST_PP_LIST_FOLD_RIGHT_D().


Prev Next Macros Headers

Revised

© Copyright Housemarque Oy 2002

Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.