###  | # Boost.Preprocessor ## Header <boost/preprocessor/list/for_each_product.hpp>

Prev Next Macros Headers

### #define BOOST_PP_LIST_FOR_EACH_PRODUCT(MACRO,SIZE_OF_TUPLE,TUPLE_OF_LISTS)

Repeats `MACRO(R,X)` for each element `X` of the cartesian product of the lists of the `SIZE_OF_TUPLE`-tuple `TUPLE_OF_LISTS`.

This macro is useful for generating code to avoid combinatorial explosion.

For example,

    #define TEST(R,X) X
    BOOST_PP_LIST_FOR_EACH_PRODUCT
    ( TEST
    , 2
    , ( BOOST_PP_TUPLE_TO_LIST(3,(A,B,C))
      , BOOST_PP_TUPLE_TO_LIST(2,(1,2))
      )
    )

expands to:

    (A,1) (A,2) (B,1) (B,2) (C,1) (C,2)

### Example

- is_integral.cpp
- array_arithmetic.c

### Test

- list_test.cpp

### #define BOOST_PP_LIST_FOR_EACH_PRODUCT_R(R,MACRO,SIZE_OF_TUPLE,TUPLE_OF_LISTS)

Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).

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.