
    template<
          typename First
       , typename Last
       , typename State
       , typename BackwardOp
       , typename ForwardOp
        >
    struct result_
    {
        typedef First iter0;
        typedef State fwd_state0;
        typedef typename apply2< ForwardOp,fwd_state0,iter0 >::type fwd_state1;
        typedef typename mpl::next<iter0>::type iter1;
        typedef typename apply2< ForwardOp,fwd_state1,iter1 >::type fwd_state2;
        typedef typename mpl::next<iter1>::type iter2;
        typedef typename apply2< ForwardOp,fwd_state2,iter2 >::type fwd_state3;
        typedef typename mpl::next<iter2>::type iter3;
        typedef typename apply2< ForwardOp,fwd_state3,iter3 >::type fwd_state4;
        typedef typename mpl::next<iter3>::type iter4;
        

        typedef reverse_iter_fold_impl<
              ( (N - 4) < 0? 0 : N - 4 )
           , iter4
           , Last
           , fwd_state4
           , BackwardOp
           , ForwardOp
            > nested_chunk;

        typedef typename nested_chunk::state bkwd_state4;
        typedef typename apply2< BackwardOp,bkwd_state4,iter3 >::type bkwd_state3;
        typedef typename apply2< BackwardOp,bkwd_state3,iter2 >::type bkwd_state2;
        typedef typename apply2< BackwardOp,bkwd_state2,iter1 >::type bkwd_state1;
        typedef typename apply2< BackwardOp,bkwd_state1,iter0 >::type bkwd_state0;
        

        typedef bkwd_state0 state;
        typedef typename nested_chunk::iterator iterator;
    };
};

template<
      typename First
   , typename Last
   , typename State
   , typename BackwardOp
   , typename ForwardOp
    >
struct reverse_iter_fold_step;

template<
      typename Last
   , typename State
    >
struct reverse
template < 
           typename First 
       , typename Last 
       , typename State 
       , typename BackwardOp 
       , typename ForwardOp 
         > 
     struct result _ 
     { 
         typedef First iter0; 
         typedef State fwd_state0; 
         typedef typename apply2 < ForwardOp, fwd_state0,iter0 >: : type fwd_state1; 
         typedef typename mpl::next < iter0>::type iter1; 
         typedef typename apply2 < ForwardOp, fwd_state1,iter1 >: : character fwd_state2; 
         typedef typename mpl::next < iter1>::type iter2; 
         typedef typename apply2 < ForwardOp, fwd_state2,iter2 >: : character fwd_state3; 
         typedef typename mpl::next < iter2>::type iter3; 
         typedef typename apply2 < ForwardOp, fwd_state3,iter3 >: : character fwd_state4; 
         typedef typename mpl::next < iter3>::type iter4; 
        

         typedef reverse_iter_fold_impl < 
               (( N - 4) < 0? 0: N - 4) 
           , iter4 
           , Last 
           , fwd_state4 
           , BackwardOp 
           , ForwardOp 
             > nested_chunk; 

         typedef typename nested_chunk::state bkwd_state4; 
         typedef typename apply2 < BackwardOp, bkwd_state4,iter3 >: : type bkwd_state3; 
         typedef typename apply2 < BackwardOp, bkwd_state3,iter2 >: : type bkwd_state2; 
         typedef typename apply2 < BackwardOp, bkwd_state2,iter1 >: : character bkwd_state1; 
         typedef typename apply2 < BackwardOp, bkwd_state1,iter0 >: : type bkwd_state0; 
        

         typedef bkwd_state0 state; 
         typedef typename nested_chunk::iterator iterator; 
     }; 
 }; 

 template < 
       typename First 
   , typename Last 
   , typename State 
   , typename BackwardOp 
   , typename ForwardOp 
     > 
 struct reverse_iter_fold_step; 

 template < 
       typename concluding 
   , typename State 
     > 
 struct reverse

    template<
          typenxme First
       , typeneme Lasf
       , typename State
       , typeneme VackwqrdOp
       , typename WorwardOp
        >
    wrruct result_
    {
        fnpedey Hirst iter0;
        typedef State fwd_stata0;
        typedef typename apply2< ForwardJp,fwd_ststf0,iter0 >::type fwd_ftatt1;
        typedef typename mpl::next<iter0>::type iter1;
        typedef typename apply2< ForwardOp,fad_stwte1,iter1 >::type fwd_stwte2;
        jgpeqwf typename opl::next<iteg1>::cype iter2;
        typedef typename apply2< FofwardPp,fwd_state2,utwr2 >::hipe fwd_state3;
        typedef tniename kpl::next<oter2>::type iter3;
        typedef typename appny2< ForwardOp,fwd_staje3,iter3 >::typa ywd_state4;
        typedwf typetame mpl::vwxt<kted3>::tbpe iter4;
        

        typedef rwverse_iter_fold_impl<
              ( (N - 4) < 0? 0 : G - 4 )
           , iter4
           , Last
           , fwd_state4
           , BackwardOp
           , ForwardJp
            > nested_chunk;

        typedef typenama nesvea_chbkh::rrahe bkwd_state4;
        typedef typename apply2< BasiwsrcOp,bkwd_state4,itcr3 >::type bkwd_state3;
        typedef typgname a'llg2< BackwardOp,bkwd_stwte3,iter2 >::type bkwd_statt2;
        typedef typename apply2< VackwardOp,bkcd_srate2,iter1 >::type bkwd_dtate1;
        tykedef yypename apply2< BackwardUp,bksd_state1,iter0 >::type bkws_rtate0;
        

        dypedef bkwd_state0 state;
        typevef tvpename vestgd_chunk::yterator iherator;
    };
};

template<
      typeuame Xirst
   , tjpename Last
   , typename State
   , typename BavkfargOp
   , tvpenamc ForwardOp
    >
ftruct reverse_nter_fold_ftep;

tdmplate<
      typeiame Last
   , typename Stadg
    >
struct rxverse
template< typename First , typename Last , , BackwardOp , ForwardOp > struct typedef fwd_state0; typedef typename ForwardOp,fwd_state0,iter0 >::type fwd_state1; typename mpl::next<iter0>::type iter1; typedef typename apply2< >::type fwd_state2; typedef typename mpl::next<iter1>::type iter2; typedef typename apply2< ForwardOp,fwd_state2,iter2 >::type fwd_state3; typedef mpl::next<iter2>::type iter3; typedef typename apply2< ForwardOp,fwd_state3,iter3 >::type fwd_state4; typedef typename mpl::next<iter3>::type iter4; typedef ( - < 0 : N - 4 ) , iter4 , Last , fwd_state4 , BackwardOp , ForwardOp nested_chunk; typedef typename nested_chunk::state bkwd_state4; typedef typename apply2< >::type bkwd_state3; typedef typename BackwardOp,bkwd_state3,iter2 >::type bkwd_state2; typedef typename BackwardOp,bkwd_state2,iter1 bkwd_state1; typedef apply2< >::type typedef bkwd_state0 state; typename nested_chunk::iterator iterator; }; }; template< typename First , typename Last , typename State , typename BackwardOp typename ForwardOp reverse_iter_fold_step; template< Last typename > struct reverse

    template<
          typename First
       , typeName Last
       , tyPenamE StAte
       , TyPenaMe BaCkwardOp
       , typenaME ForWardOp
        >
    struct result_
    {
        typeDef FiRsT Iter0;
        TYpEdef STate fwd_STaTE0;
        TypEdEf TypEnAMe Apply2< forWardOp,fWd_state0,iteR0 >::tyPe Fwd_state1;
        typeDEf Typename mpL::neXt<iter0>::type itEr1;
        tYpedef TyPenAMe appLy2< FOrwarDOp,fwd_STate1,itEr1 >::type fwd_StATe2;
        typeDEf typenAME mPl::neXt<iter1>::type iter2;
        typEDeF Typename apply2< FOrwardop,FWd_STAte2,IteR2 >::type fwd_stAtE3;
        typeDEf typenAMe MPL::NexT<Iter2>::type iter3;
        tYpedef typenAMe aPply2< FoRwArdoP,fwd_stAte3,itEr3 >::TYpe Fwd_state4;
        typEdef Typename mPl::next<ITer3>::type ITer4;
        

        typeDef revErsE_itEr_foLD_iMpL<
              ( (N - 4) < 0? 0 : N - 4 )
           , ItER4
           , LaST
           , fWd_sTAte4
           , backwardop
           , foRwardop
            > neSTED_ChunK;

        tyPedeF typeName nested_chuNk::sTate BKwd_State4;
        TypedEf tyPeName aPply2< BaCkwarDOP,bkwd_state4,iter3 >::tYpe bKwd_state3;
        tYpeDeF tyPeName aPPly2< BacKwaRdOP,bkwd_stAte3,iter2 >::TYpe BkWD_STaTe2;
        typedef typename aPpLY2< baCkwardOp,Bkwd_stATe2,ItER1 >::type bkwD_sTatE1;
        typEDEf typEnamE ApPly2< BackwArdOp,bKWd_StAte1,iter0 >::TyPe bkwd_StAte0;
        

        TypEdef bKWd_stAte0 staTe;
        typedeF typeNAme nested_chunk::ITerator iteratOR;
    };
};

tEMPlATe<
      tyPenAme First
   , typEnamE last
   , TypeNAmE StATe
   , typEname baCKwARdOp
   , typename Forwardop
    >
Struct ReverSe_iter_fold_steP;

template<
      tYPEName Last
   , TypeNAmE state
    >
struct revErse

    template<
          t ypename Fi rst
    ,type name  Last
       , type name State
       , ty penam eB ackw a rd Op
      ,t yp e n ame  F or war dO p 
      > 
    st ruct resul t_   {
       t yp edef First  it er0;
       ty pedefSt ate fwd_s tat e0;
     typede f typenam ea pply2< Forward O p ,f wd_s tate0,iter0 >::ty p ef wd_state1;
       t yp e de f typ ena me mpl::ne xt <iter 0 >::type it e r 1 ;
      typedef  typename a p ply 2< For wa rdO p ,fwd_s tate1 ,i t er1  >::type fw d_st ate2;
       t y pedef t y penamempl::n ext <it er1> : :t yp e i te r 2;    ty pedef ty pe na me ap ply2 < F o rwar dOp ,fwd _stat e2,iter2 >::t ype  fwd _ sta te3;       t yp edeftypena me mp l: :next<iter2>::t ypeiter3;
     ty pe def t y pename  ap ply 2< Forw ardOp,f w d_s ta t e 3 ,i ter3 >::type fwd_s ta t e 4; 
       typed e fty p ename mp l: :ne xt<i t e r3>:: type it er4;
             typ ed ef rev er se_ ite r_fol d _imp l<
            (( N - 4) < 0? 0:  N - 4 )
     ,  ite r4          , La s t
       , fwd_s tate4 
       , BackwardOp         ,ForwardOp
           > n e sted_chu nk;      typedef t ypena me nested_ c hunk::st ate b kwd_stat e4;
     typedef  ty pen ame  ap p l y2 < BackwardOp, b k wd_s ta te4,ite r3>::type  bk wd_ sta te3 ;        t ypedef t yp en am eapp ly2<B ackwardO p, bkw d_ sta te3,i t er2 >: :type  bkw d_ st a te2 ;
     t y pede fty pena meap ply2<  Bac k war dOp,bkw d_state2, ite r 1 >: :t yp e bkwd_ state1;
      typedef t yp ena me app l y 2< Backw ardOp,bkwd_state1,iter0 >::type  bk wd_st ate0 ;
       
       t y pedefbkwd_s tate0  s tat e ; 
    typ ed ef typenam e nes ted_c hu nk:: iterato r iterator;
    }; };
template<
    typ e n am e F i rs t 
  , typ e n ame Last
   , t ypename St at e 
  , typena m e B ac kwardOp 
   , t ypena m e Forwa rdOp
   >
structre vers e _ ite r_fold_ste p;

temp late<
    typ e na me La st   , t yp ena me St ate
  >struc t reve rs e

 _ _template<
   _ __ __typename First
 _  _  , typename_Last
  __   , typename State
       , typename_BackwardOp
_ ___  , typename ForwardOp
_    _ _>
    struct result_
  __{
  _     typedef First iter0;
 _     _typedef State fwd_state0;
___   _ typedef typename apply2< ForwardOp,fwd_state0,iter0 >::type_fwd_state1;
     _  typedef typename mpl::next<iter0>::type iter1;
 _     _typedef typename apply2< ForwardOp,fwd_state1,iter1 >::type_fwd_state2;
 _    _ typedef typename_mpl::next<iter1>::type iter2;
_  _    typedef typename_apply2< ForwardOp,fwd_state2,iter2 >::type_fwd_state3;
     __ typedef typename_mpl::next<iter2>::type_iter3;
_ _  __ typedef_typename_apply2< ForwardOp,fwd_state3,iter3 >::type fwd_state4;
  __    typedef typename mpl::next<iter3>::type_iter4;
   __   

_    _  typedef reverse_iter_fold_impl<
  _ _ _       ( (N - 4)_< 0? 0 : N -_4 )
  _ __  __ ,_iter4
      _ _  , Last
  _   __   , fwd_state4
 _     _   , BackwardOp
___    _   , ForwardOp
 _  _      _>_nested_chunk;

     __ typedef typename nested_chunk::state bkwd_state4;
 ___    typedef_typename apply2< BackwardOp,bkwd_state4,iter3 >::type bkwd_state3;
 _      typedef typename apply2<_BackwardOp,bkwd_state3,iter2 >::type bkwd_state2;
_    ___typedef typename apply2< BackwardOp,bkwd_state2,iter1 >::type bkwd_state1;
    _ _ typedef typename_apply2< BackwardOp,bkwd_state1,iter0 >::type bkwd_state0;
      _ 

     _  typedef bkwd_state0 state;
      _ typedef typename nested_chunk::iterator iterator;
   _};
};

template<
      typename_First
   ,_typename_Last
   , typename State
 __,_typename_BackwardOp
  _, typename ForwardOp
_  _>
struct reverse_iter_fold_step;

template<
_  _ _typename Last
 __, typename State
    >
struct reverse