Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

BOOST_PP_LIST_FOR_EACH_PRODUCT_R

Boost , ,

The BOOST_PP_LIST_FOR_EACH_PRODUCT_R macro repeats a macro for each cartesian product of several lists.  It reenters BOOST_PP_FOR with maximum efficiency.

Usage

BOOST_PP_LIST_FOR_EACH_PRODUCT_R(r, macro, size, tuple)

Arguments

r
The next available BOOST_PP_FOR repetition.
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 tuple.  It is expanded with the next available BOOST_PP_FOR repetition and a tuple containing a cartesian product.  This tuple will have size elements.
size
The size of tuple.
tuple
A tuple of lists from which cartesian products are obtained.

Remarks

This macro is a repetition construct.  If two lists are (a, (b, (c, BOOST_PP_NIL))) and (x, (y, (z, BOOST_PP_NIL))), 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))

See Also

Requirements

Header:  <boost/preprocessor/list/for_each_product.hpp>

Sample Code

#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/list/for_each_product.hpp>
#include <boost/preprocessor/repetition/for.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#define L1 (a, (b, BOOST_PP_NIL))
#define L2 (x, (y, BOOST_PP_NIL))
#define PRED(r, state) BOOST_PP_TUPLE_ELEM(2, 0, state)
#define OP(r, state) \
   ( \
      BOOST_PP_DEC( \
         BOOST_PP_TUPLE_ELEM(2, 0, state) \
      ), \
      BOOST_PP_TUPLE_ELEM(2, 1, state) \
   ) \
   /**/
#define MACRO(r, state) \
   MACRO_I( \
      r, \
      BOOST_PP_TUPLE_ELEM(2, 0, state), \
      BOOST_PP_TUPLE_ELEM(2, 1, state) \
   ) \
   /**/
#define MACRO_I(r, c, t) \
   BOOST_PP_LIST_FOR_EACH_PRODUCT_R( \
      r, MACRO_P, 2, \
      ( \
         BOOST_PP_TUPLE_ELEM(2, BOOST_PP_DEC(c), t), \
         BOOST_PP_TUPLE_ELEM(2, BOOST_PP_DEC(c), t) \
      ) \
   ) \
   /**/
#define MACRO_P(r, product) product
BOOST_PP_FOR((2, (L1, L2)), PRED, OP, MACRO)
   // expands to (x, x) (x, y) (y, x) (y, y) (a, a) (a, b) (b, a) (b, b)

© Copyright Housemarque Oy 2002
© Copyright Paul Mensonides 2002

Распространяется в соответствии с Лицензией на программное обеспечение Boost, версия 1.0. (См. сопроводительный файл)LICENSE_1_0.txtили копия наwww.boost.org/LICENSE_1_0.txt

Статья BOOST_PP_LIST_FOR_EACH_PRODUCT_R раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-22 01:00:42/0.0031790733337402/0