![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
BOOST_PP_FORBoost , ,
The BOOST_PP_FOR macro represents a generalized horizontal repetition construct.
Usage
BOOST_PP_FOR(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) ... ))
The r value that is passed to pred, op, and macro represents the next available BOOST_PP_FOR repetition.
Other macros that have _R suffix variants internally use BOOST_PP_FOR--for example, BOOST_PP_LIST_FOR_EACH and BOOST_PP_LIST_FOR_EACH_R.
Using these _R versions is not strictly necessary, but passing the r value (that is passed to pred, op, and macro) to these macros allows them to reenter BOOST_PP_FOR with maximum efficiency.
To directly use this r value, rather than simply passing it to another macro, see BOOST_PP_FOR_r.
Previously, this macro could not be used recursively inside BOOST_PP_FOR.
This limitation no longer exists, as the library can automatically detect the next available BOOST_PP_FOR repetition.
See AlsoRequirementsSample Code#include <boost/preprocessor/arithmetic/inc.hpp> #include <boost/preprocessor/comparison/not_equal.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(2, 0, state), \ BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2, 1, state)) \ ) \ /**/ #define OP(r, state) \ ( \ BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2, 0, state)), \ BOOST_PP_TUPLE_ELEM(2, 1, state) \ ) \ /**/ #define MACRO(r, state) BOOST_PP_TUPLE_ELEM(2, 0, state) BOOST_PP_FOR((5, 10), PRED, OP, MACRO) // expands to 5 6 7 8 9 10
© Copyright Housemarque Oy 2002
© Copyright Paul Mensonides 2002
Распространяется в соответствии с лицензией Boost Software License, Version 1.0. (См. сопроводительный файл)LICENSE_1_0.txtили копия наwww.boost.org/LICENSE_1_0.txt Статья BOOST_PP_FOR раздела может быть полезна для разработчиков на c++ и boost. Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта. :: Главная :: ::
|
||||
©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007 |