Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:41:38

0001 
0002 // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION!
0003 
0004 #if !defined(BOOST_PP_IS_ITERATING)
0005 
0006 // Copyright Aleksey Gurtovoy 2000-2004
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. 
0009 // (See accompanying file LICENSE_1_0.txt or copy at 
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // See http://www.boost.org/libs/mpl for documentation.
0013 
0014 // $Id$
0015 // $Date$
0016 // $Revision$
0017 
0018 #   include <boost/mpl/limits/unrolling.hpp>
0019 #   include <boost/mpl/aux_/preprocessor/repeat.hpp>
0020 #   include <boost/mpl/aux_/config/ctps.hpp>
0021 #   include <boost/mpl/aux_/nttp_decl.hpp>
0022 
0023 #   include <boost/preprocessor/arithmetic/sub.hpp>
0024 #   include <boost/preprocessor/iterate.hpp>
0025 #   include <boost/preprocessor/dec.hpp>
0026 #   include <boost/preprocessor/inc.hpp>
0027 #   include <boost/preprocessor/cat.hpp>
0028 
0029 // local macros, #undef-ined at the end of the header
0030 
0031 #   define AUX778076_ITER_FOLD_FORWARD_STEP(unused, n_, unused2) \
0032     typedef typename apply2< \
0033           ForwardOp \
0034         , BOOST_PP_CAT(fwd_state,n_) \
0035         , AUX778076_FOLD_IMPL_OP(BOOST_PP_CAT(iter,n_)) \
0036         >::type BOOST_PP_CAT(fwd_state,BOOST_PP_INC(n_)); \
0037     typedef typename mpl::next<BOOST_PP_CAT(iter,n_)>::type \
0038         BOOST_PP_CAT(iter,BOOST_PP_INC(n_)); \
0039     /**/
0040 
0041 #   define AUX778076_ITER_FOLD_BACKWARD_STEP_FUNC(n_) \
0042     typedef typename apply2< \
0043           BackwardOp \
0044         , BOOST_PP_CAT(bkwd_state,n_) \
0045         , AUX778076_FOLD_IMPL_OP(BOOST_PP_CAT(iter,BOOST_PP_DEC(n_))) \
0046         >::type BOOST_PP_CAT(bkwd_state,BOOST_PP_DEC(n_)); \
0047     /**/
0048 
0049 #   define AUX778076_ITER_FOLD_BACKWARD_STEP(unused, n_, j) \
0050     AUX778076_ITER_FOLD_BACKWARD_STEP_FUNC( \
0051           BOOST_PP_SUB_D(1,j,n_) \
0052         ) \
0053     /**/
0054 
0055 #   define AUX778076_FIRST_BACKWARD_STATE_TYPEDEF(n_) \
0056     typedef typename nested_chunk::state BOOST_PP_CAT(bkwd_state,n_);
0057     /**/
0058 
0059 #   define AUX778076_FOLD_IMPL_NAME \
0060     BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_impl) \
0061     /**/
0062 
0063 #   define AUX778076_FOLD_CHUNK_NAME \
0064     BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_chunk) \
0065     /**/
0066 
0067 namespace boost { namespace mpl { namespace aux {
0068 
0069 /// forward declaration
0070 template<
0071       BOOST_MPL_AUX_NTTP_DECL(long, N)
0072     , typename First
0073     , typename Last
0074     , typename State
0075     , typename BackwardOp
0076     , typename ForwardOp
0077     > 
0078 struct AUX778076_FOLD_IMPL_NAME;
0079 
0080 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
0081     && !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
0082 
0083 #   define BOOST_PP_ITERATION_PARAMS_1 \
0084     (3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/reverse_fold_impl_body.hpp>))
0085 #   include BOOST_PP_ITERATE()
0086 
0087 // implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
0088 template<
0089       BOOST_MPL_AUX_NTTP_DECL(long, N)
0090     , typename First
0091     , typename Last
0092     , typename State
0093     , typename BackwardOp
0094     , typename ForwardOp
0095     > 
0096 struct AUX778076_FOLD_IMPL_NAME
0097 {
0098     typedef First iter0;
0099     typedef State fwd_state0;
0100 
0101     BOOST_MPL_PP_REPEAT(
0102           BOOST_MPL_LIMIT_UNROLLING
0103         , AUX778076_ITER_FOLD_FORWARD_STEP
0104         , unused
0105         )
0106 
0107     typedef AUX778076_FOLD_IMPL_NAME<
0108           ( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )
0109         , BOOST_PP_CAT(iter,BOOST_MPL_LIMIT_UNROLLING)
0110         , Last
0111         , BOOST_PP_CAT(fwd_state,BOOST_MPL_LIMIT_UNROLLING)
0112         , BackwardOp
0113         , ForwardOp
0114         > nested_chunk;
0115         
0116     AUX778076_FIRST_BACKWARD_STATE_TYPEDEF(BOOST_MPL_LIMIT_UNROLLING)
0117 
0118     BOOST_MPL_PP_REPEAT(
0119           BOOST_MPL_LIMIT_UNROLLING
0120         , AUX778076_ITER_FOLD_BACKWARD_STEP
0121         , BOOST_MPL_LIMIT_UNROLLING
0122         )
0123 
0124     typedef bkwd_state0 state;
0125     typedef typename nested_chunk::iterator iterator;
0126 };
0127 
0128 // fallback implementation for sequences of unknown size
0129 template<
0130       typename First
0131     , typename Last
0132     , typename State
0133     , typename BackwardOp
0134     , typename ForwardOp
0135     > 
0136 struct AUX778076_FOLD_IMPL_NAME<-1,First,Last,State,BackwardOp,ForwardOp>
0137 {
0138     typedef AUX778076_FOLD_IMPL_NAME<
0139           -1
0140         , typename mpl::next<First>::type
0141         , Last
0142         , typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
0143         , BackwardOp
0144         , ForwardOp
0145         > nested_step;
0146 
0147     typedef typename apply2<
0148           BackwardOp
0149         , typename nested_step::state
0150         , AUX778076_FOLD_IMPL_OP(First)
0151         >::type state;
0152 
0153     typedef typename nested_step::iterator iterator;
0154 };
0155 
0156 template<
0157       typename Last
0158     , typename State
0159     , typename BackwardOp
0160     , typename ForwardOp
0161     > 
0162 struct AUX778076_FOLD_IMPL_NAME<-1,Last,Last,State,BackwardOp,ForwardOp>
0163 {
0164     typedef State state;
0165     typedef Last iterator;
0166 };
0167 
0168 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0169 
0170 template< BOOST_MPL_AUX_NTTP_DECL(long, N) >
0171 struct AUX778076_FOLD_CHUNK_NAME;
0172 
0173 #   define BOOST_PP_ITERATION_PARAMS_1 \
0174     (3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/reverse_fold_impl_body.hpp>))
0175 #   include BOOST_PP_ITERATE()
0176 
0177 // implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
0178 template< BOOST_MPL_AUX_NTTP_DECL(long, N) > 
0179 struct AUX778076_FOLD_CHUNK_NAME
0180 {
0181     template<
0182           typename First
0183         , typename Last
0184         , typename State
0185         , typename BackwardOp
0186         , typename ForwardOp
0187         > 
0188     struct result_
0189     {
0190         typedef First iter0;
0191         typedef State fwd_state0;
0192 
0193         BOOST_MPL_PP_REPEAT(
0194               BOOST_MPL_LIMIT_UNROLLING
0195             , AUX778076_ITER_FOLD_FORWARD_STEP
0196             , unused
0197             )
0198 
0199         typedef AUX778076_FOLD_IMPL_NAME<
0200               ( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )
0201             , BOOST_PP_CAT(iter,BOOST_MPL_LIMIT_UNROLLING)
0202             , Last
0203             , BOOST_PP_CAT(fwd_state,BOOST_MPL_LIMIT_UNROLLING)
0204             , BackwardOp
0205             , ForwardOp
0206             > nested_chunk;
0207             
0208         AUX778076_FIRST_BACKWARD_STATE_TYPEDEF(BOOST_MPL_LIMIT_UNROLLING)
0209 
0210         BOOST_MPL_PP_REPEAT(
0211               BOOST_MPL_LIMIT_UNROLLING
0212             , AUX778076_ITER_FOLD_BACKWARD_STEP
0213             , BOOST_MPL_LIMIT_UNROLLING
0214             )
0215 
0216         typedef bkwd_state0 state;
0217         typedef typename nested_chunk::iterator iterator;
0218     };
0219 };
0220 
0221 // fallback implementation for sequences of unknown size
0222 template<
0223       typename First
0224     , typename Last
0225     , typename State
0226     , typename BackwardOp
0227     , typename ForwardOp
0228     > 
0229 struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step);
0230 
0231 template<
0232       typename Last
0233     , typename State
0234     >
0235 struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)
0236 {
0237     typedef Last iterator;
0238     typedef State state;
0239 };
0240 
0241 template<> 
0242 struct AUX778076_FOLD_CHUNK_NAME<-1>
0243 {
0244     template<
0245           typename First
0246         , typename Last
0247         , typename State
0248         , typename BackwardOp
0249         , typename ForwardOp
0250         > 
0251     struct result_
0252     {
0253         typedef typename if_<
0254               typename is_same<First,Last>::type
0255             , BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)<Last,State>
0256             , BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)<First,Last,State,BackwardOp,ForwardOp>
0257             >::type res_;
0258 
0259         typedef typename res_::state state;
0260         typedef typename res_::iterator iterator;
0261     };
0262 
0263 #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
0264     /// ETI workaround
0265     template<> struct result_<int,int,int,int,int>
0266     {
0267         typedef int state;
0268         typedef int iterator;
0269     };
0270 #endif
0271 };
0272 
0273 template<
0274       typename First
0275     , typename Last
0276     , typename State
0277     , typename BackwardOp
0278     , typename ForwardOp
0279     > 
0280 struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)
0281 {
0282     typedef AUX778076_FOLD_CHUNK_NAME<-1>::template result_<
0283           typename mpl::next<First>::type
0284         , Last
0285         , typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
0286         , BackwardOp
0287         , ForwardOp
0288         > nested_step;
0289 
0290     typedef typename apply2<
0291           BackwardOp
0292         , typename nested_step::state
0293         , AUX778076_FOLD_IMPL_OP(First)
0294         >::type state;
0295 
0296     typedef typename nested_step::iterator iterator;
0297 };
0298 
0299 template<
0300       BOOST_MPL_AUX_NTTP_DECL(long, N)
0301     , typename First
0302     , typename Last
0303     , typename State
0304     , typename BackwardOp
0305     , typename ForwardOp
0306     > 
0307 struct AUX778076_FOLD_IMPL_NAME
0308     : AUX778076_FOLD_CHUNK_NAME<N>
0309         ::template result_<First,Last,State,BackwardOp,ForwardOp>
0310 {
0311 };
0312 
0313 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0314 
0315 }}}
0316 
0317 #   undef AUX778076_FIRST_BACKWARD_STATE_TYPEDEF
0318 #   undef AUX778076_ITER_FOLD_BACKWARD_STEP
0319 #   undef AUX778076_ITER_FOLD_BACKWARD_STEP_FUNC
0320 #   undef AUX778076_ITER_FOLD_FORWARD_STEP
0321 
0322 #undef AUX778076_FOLD_IMPL_OP
0323 #undef AUX778076_FOLD_IMPL_NAME_PREFIX
0324 
0325 ///// iteration
0326 
0327 #else
0328 
0329 #   define n_ BOOST_PP_FRAME_ITERATION(1)
0330 
0331 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
0332     && !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
0333 
0334 template<
0335       typename First
0336     , typename Last
0337     , typename State
0338     , typename BackwardOp
0339     , typename ForwardOp
0340     >
0341 struct AUX778076_FOLD_IMPL_NAME<n_,First,Last,State,BackwardOp,ForwardOp>
0342 {
0343     typedef First iter0;
0344     typedef State fwd_state0;
0345 
0346     BOOST_MPL_PP_REPEAT(
0347           n_
0348         , AUX778076_ITER_FOLD_FORWARD_STEP
0349         , unused
0350         )
0351 
0352     typedef BOOST_PP_CAT(fwd_state,n_) BOOST_PP_CAT(bkwd_state,n_);
0353 
0354     BOOST_MPL_PP_REPEAT(
0355           n_
0356         , AUX778076_ITER_FOLD_BACKWARD_STEP
0357         , n_
0358         )
0359 
0360     typedef bkwd_state0 state;
0361     typedef BOOST_PP_CAT(iter,n_) iterator;
0362 };
0363 
0364 #else
0365 
0366 template<> struct AUX778076_FOLD_CHUNK_NAME<n_>
0367 {
0368     template<
0369           typename First
0370         , typename Last
0371         , typename State
0372         , typename BackwardOp
0373         , typename ForwardOp
0374         >
0375     struct result_
0376     {
0377         typedef First iter0;
0378         typedef State fwd_state0;
0379 
0380         BOOST_MPL_PP_REPEAT(
0381               n_
0382             , AUX778076_ITER_FOLD_FORWARD_STEP
0383             , unused
0384             )
0385 
0386         typedef BOOST_PP_CAT(fwd_state,n_) BOOST_PP_CAT(bkwd_state,n_);
0387 
0388         BOOST_MPL_PP_REPEAT(
0389               n_
0390             , AUX778076_ITER_FOLD_BACKWARD_STEP
0391             , n_
0392             )
0393 
0394         typedef bkwd_state0 state;
0395         typedef BOOST_PP_CAT(iter,n_) iterator;
0396     };
0397 
0398 #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
0399     /// ETI workaround
0400     template<> struct result_<int,int,int,int,int>
0401     {
0402         typedef int state;
0403         typedef int iterator;
0404     };
0405 #endif
0406 };
0407 
0408 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0409 
0410 #   undef n_
0411 
0412 #endif // BOOST_PP_IS_ITERATING