| 1 | # /* ************************************************************************** |
| 2 | # * * |
| 3 | # * (C) Copyright Paul Mensonides 2002. |
| 4 | # * Distributed under the Boost Software License, Version 1.0. (See |
| 5 | # * accompanying file LICENSE_1_0.txt or copy at |
| 6 | # * http://www.boost.org/LICENSE_1_0.txt) |
| 7 | # * * |
| 8 | # ************************************************************************** */ |
| 9 | # |
| 10 | # /* See http://www.boost.org for most recent version. */ |
| 11 | # |
| 12 | # ifndef BOOST_PREPROCESSOR_SEQ_FOR_EACH_I_HPP |
| 13 | # define BOOST_PREPROCESSOR_SEQ_FOR_EACH_I_HPP |
| 14 | # |
| 15 | # include <boost/preprocessor/arithmetic/dec.hpp> |
| 16 | # include <boost/preprocessor/arithmetic/inc.hpp> |
| 17 | # include <boost/preprocessor/config/config.hpp> |
| 18 | # include <boost/preprocessor/control/if.hpp> |
| 19 | # include <boost/preprocessor/control/iif.hpp> |
| 20 | # include <boost/preprocessor/repetition/for.hpp> |
| 21 | # include <boost/preprocessor/seq/seq.hpp> |
| 22 | # include <boost/preprocessor/seq/size.hpp> |
| 23 | # include <boost/preprocessor/seq/detail/is_empty.hpp> |
| 24 | # include <boost/preprocessor/tuple/elem.hpp> |
| 25 | # include <boost/preprocessor/tuple/rem.hpp> |
| 26 | # |
| 27 | # /* BOOST_PP_SEQ_FOR_EACH_I */ |
| 28 | # |
| 29 | # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() |
| 30 | # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK(macro, data, seq) |
| 31 | # else |
| 32 | # define BOOST_PP_SEQ_FOR_EACH_I(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_I_I(macro, data, seq) |
| 33 | # define BOOST_PP_SEQ_FOR_EACH_I_I(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK(macro, data, seq) |
| 34 | # endif |
| 35 | # |
| 36 | # define BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK_EXEC(macro, data, seq) BOOST_PP_FOR((macro, data, seq, 0, BOOST_PP_SEQ_SIZE(seq)), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) |
| 37 | # define BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK_EMPTY(macro, data, seq) |
| 38 | # |
| 39 | # define BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK(macro, data, seq) \ |
| 40 | BOOST_PP_IIF \ |
| 41 | ( \ |
| 42 | BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY(seq), \ |
| 43 | BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK_EXEC, \ |
| 44 | BOOST_PP_SEQ_FOR_EACH_I_DETAIL_CHECK_EMPTY \ |
| 45 | ) \ |
| 46 | (macro, data, seq) \ |
| 47 | /**/ |
| 48 | # |
| 49 | # define BOOST_PP_SEQ_FOR_EACH_I_P(r, x) BOOST_PP_TUPLE_ELEM(5, 4, x) |
| 50 | # |
| 51 | # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() |
| 52 | # define BOOST_PP_SEQ_FOR_EACH_I_O(r, x) BOOST_PP_SEQ_FOR_EACH_I_O_I x |
| 53 | # else |
| 54 | # define BOOST_PP_SEQ_FOR_EACH_I_O(r, x) BOOST_PP_SEQ_FOR_EACH_I_O_I(BOOST_PP_TUPLE_ELEM(5, 0, x), BOOST_PP_TUPLE_ELEM(5, 1, x), BOOST_PP_TUPLE_ELEM(5, 2, x), BOOST_PP_TUPLE_ELEM(5, 3, x), BOOST_PP_TUPLE_ELEM(5, 4, x)) |
| 55 | # endif |
| 56 | # |
| 57 | # define BOOST_PP_SEQ_FOR_EACH_I_O_I(macro, data, seq, i, sz) \ |
| 58 | BOOST_PP_SEQ_FOR_EACH_I_O_I_DEC(macro, data, seq, i, BOOST_PP_DEC(sz)) \ |
| 59 | /**/ |
| 60 | # define BOOST_PP_SEQ_FOR_EACH_I_O_I_DEC(macro, data, seq, i, sz) \ |
| 61 | ( \ |
| 62 | macro, \ |
| 63 | data, \ |
| 64 | BOOST_PP_IF \ |
| 65 | ( \ |
| 66 | sz, \ |
| 67 | BOOST_PP_SEQ_FOR_EACH_I_O_I_TAIL, \ |
| 68 | BOOST_PP_SEQ_FOR_EACH_I_O_I_NIL \ |
| 69 | ) \ |
| 70 | (seq), \ |
| 71 | BOOST_PP_INC(i), \ |
| 72 | sz \ |
| 73 | ) \ |
| 74 | /**/ |
| 75 | # define BOOST_PP_SEQ_FOR_EACH_I_O_I_TAIL(seq) BOOST_PP_SEQ_TAIL(seq) |
| 76 | # define BOOST_PP_SEQ_FOR_EACH_I_O_I_NIL(seq) BOOST_PP_NIL |
| 77 | # |
| 78 | # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() |
| 79 | # define BOOST_PP_SEQ_FOR_EACH_I_M(r, x) BOOST_PP_SEQ_FOR_EACH_I_M_IM(r, BOOST_PP_TUPLE_REM_5 x) |
| 80 | # define BOOST_PP_SEQ_FOR_EACH_I_M_IM(r, im) BOOST_PP_SEQ_FOR_EACH_I_M_I(r, im) |
| 81 | # else |
| 82 | # define BOOST_PP_SEQ_FOR_EACH_I_M(r, x) BOOST_PP_SEQ_FOR_EACH_I_M_I(r, BOOST_PP_TUPLE_ELEM(5, 0, x), BOOST_PP_TUPLE_ELEM(5, 1, x), BOOST_PP_TUPLE_ELEM(5, 2, x), BOOST_PP_TUPLE_ELEM(5, 3, x), BOOST_PP_TUPLE_ELEM(5, 4, x)) |
| 83 | # endif |
| 84 | # |
| 85 | # define BOOST_PP_SEQ_FOR_EACH_I_M_I(r, macro, data, seq, i, sz) macro(r, data, i, BOOST_PP_SEQ_HEAD(seq)) |
| 86 | # |
| 87 | # /* BOOST_PP_SEQ_FOR_EACH_I_R */ |
| 88 | # |
| 89 | # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() |
| 90 | # define BOOST_PP_SEQ_FOR_EACH_I_R(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK(r, macro, data, seq) |
| 91 | # else |
| 92 | # define BOOST_PP_SEQ_FOR_EACH_I_R(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH_I_R_I(r, macro, data, seq) |
| 93 | # define BOOST_PP_SEQ_FOR_EACH_I_R_I(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK(r, macro, data, seq) |
| 94 | # endif |
| 95 | # |
| 96 | # define BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK_EXEC(r, macro, data, seq) BOOST_PP_FOR_ ## r((macro, data, seq, 0, BOOST_PP_SEQ_SIZE(seq)), BOOST_PP_SEQ_FOR_EACH_I_P, BOOST_PP_SEQ_FOR_EACH_I_O, BOOST_PP_SEQ_FOR_EACH_I_M) |
| 97 | # define BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK_EMPTY(r, macro, data, seq) |
| 98 | # |
| 99 | # define BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK(r, macro, data, seq) \ |
| 100 | BOOST_PP_IIF \ |
| 101 | ( \ |
| 102 | BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY(seq), \ |
| 103 | BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK_EXEC, \ |
| 104 | BOOST_PP_SEQ_FOR_EACH_I_R_DETAIL_CHECK_EMPTY \ |
| 105 | ) \ |
| 106 | (r, macro, data, seq) \ |
| 107 | /**/ |
| 108 | # |
| 109 | # endif |
| 110 | |