1 # /* **************************************************************************
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)
8 # ************************************************************************** */
10 # /* See http://www.boost.org for most recent version. */
12 # ifndef BOOST_PREPROCESSOR_SEQ_FOR_EACH_HPP
13 # define BOOST_PREPROCESSOR_SEQ_FOR_EACH_HPP
15 # include <boost/preprocessor/arithmetic/dec.hpp>
16 # include <boost/preprocessor/config/config.hpp>
17 # include <boost/preprocessor/control/if.hpp>
18 # include <boost/preprocessor/control/iif.hpp>
19 # include <boost/preprocessor/repetition/for.hpp>
20 # include <boost/preprocessor/seq/seq.hpp>
21 # include <boost/preprocessor/seq/size.hpp>
22 # include <boost/preprocessor/seq/detail/is_empty.hpp>
23 # include <boost/preprocessor/tuple/elem.hpp>
24 # include <boost/preprocessor/tuple/rem.hpp>
26 # /* BOOST_PP_SEQ_FOR_EACH */
28 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
29 # define BOOST_PP_SEQ_FOR_EACH(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK(macro, data, seq)
31 # define BOOST_PP_SEQ_FOR_EACH(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_D(macro, data, seq)
32 # define BOOST_PP_SEQ_FOR_EACH_D(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK(macro, data, seq)
35 # define BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EXEC(macro, data, seq) BOOST_PP_FOR((macro, data, seq, BOOST_PP_SEQ_SIZE(seq)), BOOST_PP_SEQ_FOR_EACH_P, BOOST_PP_SEQ_FOR_EACH_O, BOOST_PP_SEQ_FOR_EACH_M)
36 # define BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EMPTY(macro, data, seq)
38 # define BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK(macro, data, seq) \
41 BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY(seq), \
42 BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EXEC, \
43 BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EMPTY \
48 # define BOOST_PP_SEQ_FOR_EACH_P(r, x) BOOST_PP_TUPLE_ELEM(4, 3, x)
50 # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
51 # define BOOST_PP_SEQ_FOR_EACH_O(r, x) BOOST_PP_SEQ_FOR_EACH_O_I x
53 # define BOOST_PP_SEQ_FOR_EACH_O(r, x) BOOST_PP_SEQ_FOR_EACH_O_I(BOOST_PP_TUPLE_ELEM(4, 0, x), BOOST_PP_TUPLE_ELEM(4, 1, x), BOOST_PP_TUPLE_ELEM(4, 2, x), BOOST_PP_TUPLE_ELEM(4, 3, x))
56 # define BOOST_PP_SEQ_FOR_EACH_O_I(macro, data, seq, sz) \
57 BOOST_PP_SEQ_FOR_EACH_O_I_DEC(macro, data, seq, BOOST_PP_DEC(sz)) \
59 # define BOOST_PP_SEQ_FOR_EACH_O_I_DEC(macro, data, seq, sz) \
66 BOOST_PP_SEQ_FOR_EACH_O_I_TAIL, \
67 BOOST_PP_SEQ_FOR_EACH_O_I_NIL \
73 # define BOOST_PP_SEQ_FOR_EACH_O_I_TAIL(seq) BOOST_PP_SEQ_TAIL(seq)
74 # define BOOST_PP_SEQ_FOR_EACH_O_I_NIL(seq) BOOST_PP_NIL
76 # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
77 # define BOOST_PP_SEQ_FOR_EACH_M(r, x) BOOST_PP_SEQ_FOR_EACH_M_IM(r, BOOST_PP_TUPLE_REM_4 x)
78 # define BOOST_PP_SEQ_FOR_EACH_M_IM(r, im) BOOST_PP_SEQ_FOR_EACH_M_I(r, im)
80 # define BOOST_PP_SEQ_FOR_EACH_M(r, x) BOOST_PP_SEQ_FOR_EACH_M_I(r, BOOST_PP_TUPLE_ELEM(4, 0, x), BOOST_PP_TUPLE_ELEM(4, 1, x), BOOST_PP_TUPLE_ELEM(4, 2, x), BOOST_PP_TUPLE_ELEM(4, 3, x))
83 # define BOOST_PP_SEQ_FOR_EACH_M_I(r, macro, data, seq, sz) macro(r, data, BOOST_PP_SEQ_HEAD(seq))
85 # /* BOOST_PP_SEQ_FOR_EACH_R */
87 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
88 # define BOOST_PP_SEQ_FOR_EACH_R(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_R(r, macro, data, seq)
90 # define BOOST_PP_SEQ_FOR_EACH_R(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH_R_I(r, macro, data, seq)
91 # define BOOST_PP_SEQ_FOR_EACH_R_I(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_R(r, macro, data, seq)
94 # define BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EXEC_R(r, macro, data, seq) BOOST_PP_FOR_ ## r((macro, data, seq, BOOST_PP_SEQ_SIZE(seq)), BOOST_PP_SEQ_FOR_EACH_P, BOOST_PP_SEQ_FOR_EACH_O, BOOST_PP_SEQ_FOR_EACH_M)
95 # define BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EMPTY_R(r, macro, data, seq)
97 # define BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_R(r, macro, data, seq) \
100 BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY(seq), \
101 BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EXEC_R, \
102 BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK_EMPTY_R \
104 (r, macro, data, seq) \