File indexing completed on 2025-01-18 09:53:37
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_VMD_DETAIL_SEQ_HPP)
0008 #define BOOST_VMD_DETAIL_SEQ_HPP
0009
0010 #include <boost/preprocessor/comparison/equal.hpp>
0011 #include <boost/preprocessor/control/iif.hpp>
0012 #include <boost/preprocessor/control/while.hpp>
0013 #include <boost/preprocessor/facilities/empty.hpp>
0014 #include <boost/preprocessor/seq/push_back.hpp>
0015 #include <boost/preprocessor/tuple/elem.hpp>
0016 #include <boost/preprocessor/tuple/push_back.hpp>
0017 #include <boost/preprocessor/tuple/size.hpp>
0018 #include <boost/preprocessor/variadic/elem.hpp>
0019 #include <boost/vmd/is_empty.hpp>
0020 #include <boost/vmd/detail/empty_result.hpp>
0021 #include <boost/vmd/detail/mods.hpp>
0022 #include <boost/vmd/detail/not_empty.hpp>
0023 #include <boost/vmd/detail/parens.hpp>
0024
0025 #define BOOST_VMD_DETAIL_SEQ_STATE_INIT(seq) \
0026 BOOST_PP_TUPLE_PUSH_BACK \
0027 ( \
0028 BOOST_PP_TUPLE_PUSH_BACK \
0029 ( \
0030 BOOST_VMD_DETAIL_PARENS(seq,BOOST_VMD_RETURN_AFTER), \
0031 BOOST_PP_EMPTY() \
0032 ), \
0033 BOOST_PP_EMPTY() \
0034 ) \
0035
0036
0037 #define BOOST_VMD_DETAIL_SEQ_STATE_INIT_D(d,seq) \
0038 BOOST_PP_TUPLE_PUSH_BACK \
0039 ( \
0040 BOOST_PP_TUPLE_PUSH_BACK \
0041 ( \
0042 BOOST_VMD_DETAIL_PARENS_D(d,seq,BOOST_VMD_RETURN_AFTER), \
0043 BOOST_PP_EMPTY() \
0044 ), \
0045 BOOST_PP_EMPTY() \
0046 ) \
0047
0048
0049 #define BOOST_VMD_DETAIL_SEQ_STATE_PRED(d,state) \
0050 BOOST_VMD_DETAIL_NOT_EMPTY \
0051 ( \
0052 BOOST_PP_TUPLE_ELEM(0,state) \
0053 ) \
0054
0055
0056 #define BOOST_VMD_DETAIL_SEQ_STATE_OP_SET_FAILURE(d,state) \
0057 ( \
0058 BOOST_PP_EMPTY(), \
0059 BOOST_PP_EMPTY(), \
0060 BOOST_PP_TUPLE_ELEM(2,state), \
0061 BOOST_PP_TUPLE_ELEM(3,state) \
0062 ) \
0063
0064
0065 #define BOOST_VMD_DETAIL_SEQ_STATE_OP_MAKE_SEQ(d,state) \
0066 BOOST_PP_TUPLE_ELEM(0,state) \
0067
0068
0069 #define BOOST_VMD_DETAIL_SEQ_STATE_OP_UPGRADE_SEQ(d,state) \
0070 BOOST_PP_SEQ_PUSH_BACK \
0071 ( \
0072 BOOST_PP_TUPLE_ELEM(2,state), \
0073 BOOST_PP_TUPLE_ELEM \
0074 ( \
0075 0, \
0076 BOOST_PP_TUPLE_ELEM(0,state) \
0077 ) \
0078 ) \
0079
0080
0081 #define BOOST_VMD_DETAIL_SEQ_STATE_OP_SET_SUCCESS(d,state) \
0082 ( \
0083 BOOST_PP_EMPTY(), \
0084 BOOST_PP_EMPTY(), \
0085 BOOST_PP_IIF \
0086 ( \
0087 BOOST_VMD_IS_EMPTY \
0088 ( \
0089 BOOST_PP_TUPLE_ELEM(2,state) \
0090 ), \
0091 BOOST_VMD_DETAIL_SEQ_STATE_OP_MAKE_SEQ, \
0092 BOOST_VMD_DETAIL_SEQ_STATE_OP_UPGRADE_SEQ \
0093 ) \
0094 (d,state), \
0095 BOOST_PP_EMPTY() \
0096 ) \
0097
0098
0099 #define BOOST_VMD_DETAIL_SEQ_STATE_OP_SET_CONTINUE(d,state) \
0100 BOOST_PP_TUPLE_PUSH_BACK \
0101 ( \
0102 BOOST_PP_TUPLE_PUSH_BACK \
0103 ( \
0104 BOOST_VMD_DETAIL_PARENS_D(d,BOOST_PP_TUPLE_ELEM(1,state),BOOST_VMD_RETURN_AFTER), \
0105 BOOST_PP_IIF \
0106 ( \
0107 BOOST_VMD_IS_EMPTY \
0108 ( \
0109 BOOST_PP_TUPLE_ELEM(2,state) \
0110 ), \
0111 BOOST_VMD_DETAIL_SEQ_STATE_OP_MAKE_SEQ, \
0112 BOOST_VMD_DETAIL_SEQ_STATE_OP_UPGRADE_SEQ \
0113 ) \
0114 (d,state) \
0115 ), \
0116 BOOST_PP_TUPLE_ELEM(1,state) \
0117 ) \
0118
0119
0120 #define BOOST_VMD_DETAIL_SEQ_STATE_OP_CHECK_REST(d,state) \
0121 BOOST_PP_IIF \
0122 ( \
0123 BOOST_VMD_IS_EMPTY \
0124 ( \
0125 BOOST_PP_TUPLE_ELEM(1,state) \
0126 ), \
0127 BOOST_VMD_DETAIL_SEQ_STATE_OP_SET_SUCCESS, \
0128 BOOST_VMD_DETAIL_SEQ_STATE_OP_SET_CONTINUE \
0129 ) \
0130 (d,state) \
0131
0132
0133 #define BOOST_VMD_DETAIL_SEQ_STATE_OP(d,state) \
0134 BOOST_PP_IIF \
0135 ( \
0136 BOOST_PP_EQUAL_D \
0137 ( \
0138 d, \
0139 1, \
0140 BOOST_PP_TUPLE_SIZE \
0141 ( \
0142 BOOST_PP_TUPLE_ELEM(0,state) \
0143 ) \
0144 ), \
0145 BOOST_VMD_DETAIL_SEQ_STATE_OP_CHECK_REST, \
0146 BOOST_VMD_DETAIL_SEQ_STATE_OP_SET_FAILURE \
0147 ) \
0148 (d,state) \
0149
0150
0151 #define BOOST_VMD_DETAIL_SEQ_STATE_RESULT(state) \
0152 ( \
0153 BOOST_PP_TUPLE_ELEM(2,state), \
0154 BOOST_PP_TUPLE_ELEM(3,state) \
0155 ) \
0156
0157
0158 #define BOOST_VMD_DETAIL_SEQ_PROCESS(seq) \
0159 BOOST_VMD_DETAIL_SEQ_STATE_RESULT \
0160 ( \
0161 BOOST_PP_WHILE \
0162 ( \
0163 BOOST_VMD_DETAIL_SEQ_STATE_PRED, \
0164 BOOST_VMD_DETAIL_SEQ_STATE_OP, \
0165 BOOST_VMD_DETAIL_SEQ_STATE_INIT(seq) \
0166 ) \
0167 ) \
0168
0169
0170 #define BOOST_VMD_DETAIL_SEQ_SPLIT(seq) \
0171 BOOST_PP_IIF \
0172 ( \
0173 BOOST_VMD_IS_EMPTY(seq), \
0174 BOOST_VMD_DETAIL_EMPTY_RESULT, \
0175 BOOST_VMD_DETAIL_SEQ_PROCESS \
0176 ) \
0177 (seq) \
0178
0179
0180 #define BOOST_VMD_DETAIL_SEQ_BEGIN(seq) \
0181 BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_DETAIL_SEQ_SPLIT(seq)) \
0182
0183
0184 #define BOOST_VMD_DETAIL_SEQ_PROCESS_D(d,seq) \
0185 BOOST_VMD_DETAIL_SEQ_STATE_RESULT \
0186 ( \
0187 BOOST_PP_WHILE_ ## d \
0188 ( \
0189 BOOST_VMD_DETAIL_SEQ_STATE_PRED, \
0190 BOOST_VMD_DETAIL_SEQ_STATE_OP, \
0191 BOOST_VMD_DETAIL_SEQ_STATE_INIT_D(d,seq) \
0192 ) \
0193 ) \
0194
0195
0196 #define BOOST_VMD_DETAIL_SEQ_SPLIT_D(d,seq) \
0197 BOOST_PP_IIF \
0198 ( \
0199 BOOST_VMD_IS_EMPTY(seq), \
0200 BOOST_VMD_DETAIL_EMPTY_RESULT, \
0201 BOOST_VMD_DETAIL_SEQ_PROCESS_D \
0202 ) \
0203 (d,seq) \
0204
0205
0206 #define BOOST_VMD_DETAIL_SEQ_BEGIN_D(d,seq) \
0207 BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_DETAIL_SEQ_SPLIT_D(d,seq)) \
0208
0209
0210 #define BOOST_VMD_DETAIL_SEQ_D(d,...) \
0211 BOOST_PP_IIF \
0212 ( \
0213 BOOST_VMD_DETAIL_MODS_IS_RESULT_AFTER \
0214 ( \
0215 BOOST_VMD_DETAIL_NEW_MODS_D(d,BOOST_VMD_ALLOW_AFTER,__VA_ARGS__) \
0216 ), \
0217 BOOST_VMD_DETAIL_SEQ_SPLIT_D, \
0218 BOOST_VMD_DETAIL_SEQ_BEGIN_D \
0219 ) \
0220 (d,BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
0221
0222
0223 #define BOOST_VMD_DETAIL_SEQ(...) \
0224 BOOST_PP_IIF \
0225 ( \
0226 BOOST_VMD_DETAIL_MODS_IS_RESULT_AFTER \
0227 ( \
0228 BOOST_VMD_DETAIL_NEW_MODS(BOOST_VMD_ALLOW_AFTER,__VA_ARGS__) \
0229 ), \
0230 BOOST_VMD_DETAIL_SEQ_SPLIT, \
0231 BOOST_VMD_DETAIL_SEQ_BEGIN \
0232 ) \
0233 (BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
0234
0235
0236 #endif