![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
BOOST_PP_FOR_rBoost , , The BOOST_PP_FOR_r macro
represents a reentry into the BOOST_PP_FOR repetition construct.
Usage BOOST_PP_FOR_ ## r(state, pred,
op, macro)
Arguments
Remarks This macro expands to the sequence:
macro(r, state) macro(r, op(r,
state)) ... macro(r, op(r, ... op(r,
state) ... ))
At certain times, it may be necessary to perform the concatenation
with BOOST_PP_CAT rather than the preprocessor token-pasting
operator. This happens when the r value is a macro
invocation itself. It needs a delay to allow it to expand. The
syntax in such a scenario becomes:
BOOST_PP_CAT(BOOST_PP_FOR_, r)(state,
pred, op, macro)
See AlsoRequirementsSample Code#include <boost/preprocessor/arithmetic/dec.hpp> #include <boost/preprocessor/arithmetic/inc.hpp> #include <boost/preprocessor/comparison/not_equal.hpp> #include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/repetition/for.hpp> #include <boost/preprocessor/tuple/elem.hpp> #define PRED(r, state) \ BOOST_PP_NOT_EQUAL( \ BOOST_PP_TUPLE_ELEM(4, 0, state), \ BOOST_PP_INC( \ BOOST_PP_TUPLE_ELEM(4, 1, state) \ ) \ ) \ /**/ #define OP(r, state) \ ( \ BOOST_PP_INC( \ BOOST_PP_TUPLE_ELEM(4, 0, state) \ ), \ BOOST_PP_TUPLE_ELEM(4, 1, state), \ BOOST_PP_TUPLE_ELEM(4, 2, state), \ BOOST_PP_INC( \ BOOST_PP_TUPLE_ELEM(4, 3, state) \ ) \ ) \ /**/ #define MACRO(r, state) \ BOOST_PP_COMMA_IF( \ BOOST_PP_TUPLE_ELEM(4, 3, state) \ ) template< \ BOOST_PP_FOR_ ## r( \ (0, BOOST_PP_TUPLE_ELEM(4, 0, state), _, 0), \ PRED_2, OP, MACRO_2 \ ) \ > class BOOST_PP_CAT( \ BOOST_PP_TUPLE_ELEM(4, 2, state), \ BOOST_PP_TUPLE_ELEM(4, 0, state) \ ) \ /**/ #define PRED_2(r, state) \ BOOST_PP_NOT_EQUAL( \ BOOST_PP_TUPLE_ELEM(4, 0, state), \ BOOST_PP_TUPLE_ELEM(4, 1, state) \ ) \ /**/ #define MACRO_2(r, state) \ BOOST_PP_COMMA_IF( \ BOOST_PP_TUPLE_ELEM(4, 0, state) \ ) class \ /**/ #define TEMPLATE_TEMPLATE(low, high, name) \ BOOST_PP_FOR( \ (low, high, name, 0), \ PRED, OP, MACRO \ ) \ /**/ TEMPLATE_TEMPLATE(2, 4, T) /* expands to... template<class, class> class T2, template<class, class, class> class T3, template<class, class, class, class> class T4 */ Distributed under the Boost Software License, Version 1.0. (См. сопроводительный файл LICENSE_1_0.txt или копия на www.boost.org/LICENSE_1_0.txt) Статья BOOST_PP_FOR_r раздела может быть полезна для разработчиков на c++ и boost. Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта. :: Главная :: ::
|
||||
©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007 |