File indexing completed on 2025-01-18 09:50:31
0001 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
0002
0003 #include <boost/proto/transform/detail/preprocessed/fold_impl.hpp>
0004
0005 #elif !defined(BOOST_PP_IS_ITERATING)
0006
0007 #define BOOST_PROTO_CHILD_N_TYPE(N) \
0008 BOOST_PP_CAT(proto_child, N) \
0009
0010
0011 #define BOOST_PROTO_FOLD_STATE_TYPE(Z, N, DATA) \
0012 typedef \
0013 typename when<_, Fun>::template impl< \
0014 typename result_of::child_c<Expr, N>::type \
0015 , BOOST_PP_CAT(state, N) \
0016 , Data \
0017 >::result_type \
0018 BOOST_PP_CAT(state, BOOST_PP_INC(N)); \
0019
0020
0021 #define BOOST_PROTO_FOLD_STATE(Z, N, DATA) \
0022 BOOST_PP_CAT(state, BOOST_PP_INC(N)) \
0023 BOOST_PP_CAT(s, BOOST_PP_INC(N)) \
0024 = typename when<_, Fun>::template impl< \
0025 typename result_of::child_c<Expr, N>::type \
0026 , BOOST_PP_CAT(state, N) \
0027 , Data \
0028 >()( \
0029 proto::child_c<N>(e) \
0030 , BOOST_PP_CAT(s, N) \
0031 , d \
0032 ); \
0033
0034
0035 #define BOOST_PROTO_REVERSE_FOLD_STATE_TYPE(Z, N, DATA) \
0036 typedef \
0037 typename when<_, Fun>::template impl< \
0038 typename result_of::child_c< \
0039 Expr \
0040 , BOOST_PP_SUB(DATA, BOOST_PP_INC(N)) \
0041 >::type \
0042 , BOOST_PP_CAT(state, BOOST_PP_SUB(DATA, N)) \
0043 , Data \
0044 >::result_type \
0045 BOOST_PP_CAT(state, BOOST_PP_SUB(DATA, BOOST_PP_INC(N))); \
0046
0047
0048 #define BOOST_PROTO_REVERSE_FOLD_STATE(Z, N, DATA) \
0049 BOOST_PP_CAT(state, BOOST_PP_SUB(DATA, BOOST_PP_INC(N))) \
0050 BOOST_PP_CAT(s, BOOST_PP_SUB(DATA, BOOST_PP_INC(N))) \
0051 = typename when<_, Fun>::template impl< \
0052 typename result_of::child_c< \
0053 Expr \
0054 , BOOST_PP_SUB(DATA, BOOST_PP_INC(N)) \
0055 >::type \
0056 , BOOST_PP_CAT(state, BOOST_PP_SUB(DATA, N)) \
0057 , Data \
0058 >()( \
0059 proto::child_c<BOOST_PP_SUB(DATA, BOOST_PP_INC(N))>(e) \
0060 , BOOST_PP_CAT(s, BOOST_PP_SUB(DATA, N)) \
0061 , d \
0062 ); \
0063
0064
0065 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0066 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/fold_impl.hpp")
0067 #endif
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0078 #pragma wave option(preserve: 1)
0079 #endif
0080
0081 #define BOOST_PP_ITERATION_PARAMS_1 \
0082 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/fold_impl.hpp>))
0083 #include BOOST_PP_ITERATE()
0084
0085 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0086 #pragma wave option(output: null)
0087 #endif
0088
0089 #undef BOOST_PROTO_REVERSE_FOLD_STATE
0090 #undef BOOST_PROTO_REVERSE_FOLD_STATE_TYPE
0091 #undef BOOST_PROTO_FOLD_STATE
0092 #undef BOOST_PROTO_FOLD_STATE_TYPE
0093 #undef BOOST_PROTO_CHILD_N_TYPE
0094
0095 #else
0096
0097 #define N BOOST_PP_ITERATION()
0098
0099 template<typename State0, typename Fun, typename Expr, typename State, typename Data>
0100 struct fold_impl<State0, Fun, Expr, State, Data, N>
0101 : transform_impl<Expr, State, Data>
0102 {
0103 typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
0104 BOOST_PP_REPEAT(N, BOOST_PROTO_FOLD_STATE_TYPE, N)
0105 typedef BOOST_PP_CAT(state, N) result_type;
0106
0107 result_type operator ()(
0108 typename fold_impl::expr_param e
0109 , typename fold_impl::state_param s
0110 , typename fold_impl::data_param d
0111 ) const
0112 {
0113 state0 s0 =
0114 typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
0115 BOOST_PP_REPEAT(N, BOOST_PROTO_FOLD_STATE, N)
0116 return BOOST_PP_CAT(s, N);
0117 }
0118 };
0119
0120 template<typename State0, typename Fun, typename Expr, typename State, typename Data>
0121 struct reverse_fold_impl<State0, Fun, Expr, State, Data, N>
0122 : transform_impl<Expr, State, Data>
0123 {
0124 typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type BOOST_PP_CAT(state, N);
0125 BOOST_PP_REPEAT(N, BOOST_PROTO_REVERSE_FOLD_STATE_TYPE, N)
0126 typedef state0 result_type;
0127
0128 result_type operator ()(
0129 typename reverse_fold_impl::expr_param e
0130 , typename reverse_fold_impl::state_param s
0131 , typename reverse_fold_impl::data_param d
0132 ) const
0133 {
0134 BOOST_PP_CAT(state, N) BOOST_PP_CAT(s, N) =
0135 typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
0136 BOOST_PP_REPEAT(N, BOOST_PROTO_REVERSE_FOLD_STATE, N)
0137 return s0;
0138 }
0139 };
0140
0141 #undef N
0142
0143 #endif