###

# Boost.Preprocessor

## Reference

Prev Next Macros Headers

# #include <boost/preprocessor/list/transform.hpp>

## #define BOOST_PP_LIST_TRANSFORM(OP,DATA,LIST)

Applies the macro `OP(D,DATA,X)` to each element `X` of the list producing a new list.

In other words, expands to:

      BOOST_PP_LIST_CONS(OP(D,DATA,BOOST_PP_LIST_AT(LIST,0)),
      BOOST_PP_LIST_CONS(OP(D,DATA,BOOST_PP_LIST_AT(LIST,1)),
      ...
      BOOST_PP_LIST_CONS(OP(D,DATA,BOOST_PP_LIST_AT(LIST,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST)))),
      BOOST_PP_LIST_NIL) ... ))

For example,

      BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D,2,BOOST_PP_TUPLE_TO_LIST(2,(1,2)))

expands to the same as:

      BOOST_PP_TUPLE_TO_LIST(2,(3,4))

### Uses

- BOOST_PP_WHILE() (see for explanation of the D parameter)
- BOOST_PP_LIST_FOLD_RIGHT()

### Test

- list_test.cpp

## #define BOOST_PP_LIST_TRANSFORM_D(D,OP,DATA,LIST)

Can be used inside BOOST_PP_WHILE().

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.