File indexing completed on 2025-01-18 09:41:38
0001
0002 #ifndef BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED
0003 #define BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
0019 # include <boost/mpl/identity.hpp>
0020 # include <boost/mpl/next.hpp>
0021 # include <boost/mpl/if.hpp>
0022 # include <boost/mpl/apply.hpp>
0023 # include <boost/mpl/aux_/value_wknd.hpp>
0024 #endif
0025
0026 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
0027
0028 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
0029 && !defined(BOOST_MPL_PREPROCESSING_MODE)
0030
0031 # define BOOST_MPL_PREPROCESSED_HEADER iter_fold_if_impl.hpp
0032 # include <boost/mpl/aux_/include_preprocessed.hpp>
0033
0034 #else
0035
0036 # include <boost/mpl/limits/unrolling.hpp>
0037 # include <boost/preprocessor/arithmetic/sub.hpp>
0038 # include <boost/preprocessor/repeat.hpp>
0039 # include <boost/preprocessor/inc.hpp>
0040 # include <boost/preprocessor/dec.hpp>
0041 # include <boost/preprocessor/cat.hpp>
0042
0043 namespace boost { namespace mpl { namespace aux {
0044
0045 template< typename Iterator, typename State >
0046 struct iter_fold_if_null_step
0047 {
0048 typedef State state;
0049 typedef Iterator iterator;
0050 };
0051
0052 template< bool >
0053 struct iter_fold_if_step_impl
0054 {
0055 template<
0056 typename Iterator
0057 , typename State
0058 , typename StateOp
0059 , typename IteratorOp
0060 >
0061 struct result_
0062 {
0063 typedef typename apply2<StateOp,State,Iterator>::type state;
0064 typedef typename IteratorOp::type iterator;
0065 };
0066 };
0067
0068 template<>
0069 struct iter_fold_if_step_impl<false>
0070 {
0071 template<
0072 typename Iterator
0073 , typename State
0074 , typename StateOp
0075 , typename IteratorOp
0076 >
0077 struct result_
0078 {
0079 typedef State state;
0080 typedef Iterator iterator;
0081 };
0082 };
0083
0084
0085
0086
0087 template<
0088 typename Iterator
0089 , typename State
0090 , typename ForwardOp
0091 , typename Predicate
0092 >
0093 struct iter_fold_if_forward_step
0094 {
0095 typedef typename apply2<Predicate,State,Iterator>::type not_last;
0096 typedef typename iter_fold_if_step_impl<
0097 BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value
0098 >::template result_< Iterator,State,ForwardOp,mpl::next<Iterator> > impl_;
0099
0100 typedef typename impl_::state state;
0101 typedef typename impl_::iterator iterator;
0102 };
0103
0104 template<
0105 typename Iterator
0106 , typename State
0107 , typename BackwardOp
0108 , typename Predicate
0109 >
0110 struct iter_fold_if_backward_step
0111 {
0112 typedef typename apply2<Predicate,State,Iterator>::type not_last;
0113 typedef typename iter_fold_if_step_impl<
0114 BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value
0115 >::template result_< Iterator,State,BackwardOp,identity<Iterator> > impl_;
0116
0117 typedef typename impl_::state state;
0118 typedef typename impl_::iterator iterator;
0119 };
0120
0121
0122
0123
0124 # define AUX_ITER_FOLD_FORWARD_STEP(unused, i, unused2) \
0125 typedef iter_fold_if_forward_step< \
0126 typename BOOST_PP_CAT(forward_step,i)::iterator \
0127 , typename BOOST_PP_CAT(forward_step,i)::state \
0128 , ForwardOp \
0129 , ForwardPredicate \
0130 > BOOST_PP_CAT(forward_step, BOOST_PP_INC(i)); \
0131
0132
0133 # define AUX_ITER_FOLD_BACKWARD_STEP_FUNC(i) \
0134 typedef iter_fold_if_backward_step< \
0135 typename BOOST_PP_CAT(forward_step,BOOST_PP_DEC(i))::iterator \
0136 , typename BOOST_PP_CAT(backward_step,i)::state \
0137 , BackwardOp \
0138 , BackwardPredicate \
0139 > BOOST_PP_CAT(backward_step,BOOST_PP_DEC(i)); \
0140
0141
0142 # define AUX_ITER_FOLD_BACKWARD_STEP(unused, i, unused2) \
0143 AUX_ITER_FOLD_BACKWARD_STEP_FUNC( \
0144 BOOST_PP_SUB_D(1,BOOST_MPL_LIMIT_UNROLLING,i) \
0145 ) \
0146
0147
0148 # define AUX_LAST_FORWARD_STEP \
0149 BOOST_PP_CAT(forward_step, BOOST_MPL_LIMIT_UNROLLING) \
0150
0151
0152 # define AUX_LAST_BACKWARD_STEP \
0153 BOOST_PP_CAT(backward_step, BOOST_MPL_LIMIT_UNROLLING) \
0154
0155
0156 template<
0157 typename Iterator
0158 , typename State
0159 , typename ForwardOp
0160 , typename ForwardPredicate
0161 , typename BackwardOp
0162 , typename BackwardPredicate
0163 >
0164 struct iter_fold_if_impl
0165 {
0166 private:
0167 typedef iter_fold_if_null_step<Iterator,State> forward_step0;
0168 BOOST_PP_REPEAT(
0169 BOOST_MPL_LIMIT_UNROLLING
0170 , AUX_ITER_FOLD_FORWARD_STEP
0171 , unused
0172 )
0173
0174 typedef typename if_<
0175 typename AUX_LAST_FORWARD_STEP::not_last
0176 , iter_fold_if_impl<
0177 typename AUX_LAST_FORWARD_STEP::iterator
0178 , typename AUX_LAST_FORWARD_STEP::state
0179 , ForwardOp
0180 , ForwardPredicate
0181 , BackwardOp
0182 , BackwardPredicate
0183 >
0184 , iter_fold_if_null_step<
0185 typename AUX_LAST_FORWARD_STEP::iterator
0186 , typename AUX_LAST_FORWARD_STEP::state
0187 >
0188 >::type AUX_LAST_BACKWARD_STEP;
0189
0190 BOOST_PP_REPEAT(
0191 BOOST_MPL_LIMIT_UNROLLING
0192 , AUX_ITER_FOLD_BACKWARD_STEP
0193 , unused
0194 )
0195
0196 public:
0197 typedef typename backward_step0::state state;
0198 typedef typename AUX_LAST_BACKWARD_STEP::iterator iterator;
0199 };
0200
0201 # undef AUX_LAST_BACKWARD_STEP
0202 # undef AUX_LAST_FORWARD_STEP
0203 # undef AUX_ITER_FOLD_BACKWARD_STEP
0204 # undef AUX_ITER_FOLD_BACKWARD_STEP_FUNC
0205 # undef AUX_ITER_FOLD_FORWARD_STEP
0206
0207 }}}
0208
0209 #endif
0210 #endif