The BOOST_PP_SEQ_FOR_EACH_PRODUCT macro repeats a macro for each
cartesian product of several seqs.
Usage
BOOST_PP_SEQ_FOR_EACH_PRODUCT(macro, seqs)
Arguments
- macro
-
The binary macro of the form macro(r, product). This
macro is expanded by BOOST_PP_FOR_EACH_PRODUCT with each cartesian
product in seqs. It is expanded with the next available BOOST_PP_FOR
repetition and a seq containing a cartesian product.
- seqs
-
A seq of seqs from which cartesian products are obtained.
Remarks
This macro is a repetition construct. If two
seqs are (
a)(
b)(
c)
and (
x)(
y)(
z), this macro will produce the following
sequence:
macro(r, (a)(x)) macro(r, (a)(y))
macro(r, (a)(z)) \
macro(r, (b)(x)) macro(r, (b)(y))
macro(r, (b)(z)) \
macro(r, (c)(x)) macro(r, (c)(y))
macro(r, (c)(z))
For maximum efficiency, use BOOST_PP_SEQ_FOR_EACH_PRODUCT_R.
See Also
Requirements
Sample Code
#include <boost/preprocessor/seq/for_each_product.hpp>
#include <boost/preprocessor/seq/to_tuple.hpp>
#define S1 (a)(b)(c)
#define S2 (x)(y)(z)
#define S3 (p)(q)
#define MACRO(r, product) BOOST_PP_SEQ_TO_TUPLE(product)
BOOST_PP_SEQ_FOR_EACH_PRODUCT(MACRO, (S1)(S2)(S3))
// expands to:
// (a, x, p) (a, x, q) (a, y, p) (a, y, q) (a, z, p) (a, z, q)
// (b, x, p) (b, x, q) (b, y, p) (b, y, q) (b, z, p) (b, z, q)
// (c, x, p) (c, x, q) (c, y, p) (c, y, q) (c, z, p) (c, z, q)