/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2007 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) This is an auto-generated file. Do not edit! ==============================================================================*/ namespace boost { namespace fusion { namespace detail { template struct fold_lvalue_state : boost::result_of< F( typename add_reference::type>::type, typename fusion::result_of::deref::type) > {}; template struct unrolled_fold { template static Result call(State const& state,It0 const& it0,F f) { typedef typename result_of::next< It0 const >::type It1; It1 it1 = fusion::next(it0); typedef typename result_of::next< It1 >::type It2; It2 it2 = fusion::next(it1); typedef typename result_of::next< It2 >::type It3; It3 it3 = fusion::next(it2); typedef typename fold_lvalue_state::type State1; State1 const state1=f(state,fusion::deref(it0)); typedef typename fold_lvalue_state::type State2; State2 const state2=f(state1,fusion::deref(it1)); typedef typename fold_lvalue_state::type State3; State3 const state3=f(state2,fusion::deref(it2)); return unrolled_fold< Result , N-4 >::call( f(state3,fusion::deref(it3)), fusion::next(it3), f); } }; template struct unrolled_fold { template static Result call(State const& state,It0 const& it0,F f) { typedef typename result_of::next< It0 const >::type It1; It1 it1 = fusion::next(it0); typedef typename result_of::next< It1 >::type It2; It2 it2 = fusion::next(it1); typedef typename fold_lvalue_state::type State1; State1 const state1=f(state,fusion::deref(it0)); typedef typename fold_lvalue_state::type State2; State2 const state2=f(state1,fusion::deref(it1)); return f(state2,fusion::deref(it2)); } }; template struct unrolled_fold { template static Result call(State const& state,It0 const& it0,F f) { typedef typename fold_lvalue_state::type State1; State1 const state1=f(state,fusion::deref(it0)); return f( state1, fusion::deref( fusion::next(it0))); } }; template struct unrolled_fold { template static Result call(State const& state,It0 const& it0,F f) { return f(state, fusion::deref(it0)); } }; template struct unrolled_fold { template static Result call(State const& state,It0 const& it0, F) { return static_cast(state); } }; template struct result_of_unrolled_fold { typedef typename fold_lvalue_state< StateRef , It0 const , F >::type rest1; typedef typename result_of::next< It0 const >::type it1; typedef typename fold_lvalue_state< rest1 , it1 , F >::type rest2; typedef typename result_of::next::type it2; typedef typename fold_lvalue_state< rest2 , it2 , F >::type rest3; typedef typename result_of::next::type it3; typedef typename result_of_unrolled_fold< typename fold_lvalue_state< rest3 , it3 , F >::type , typename result_of::next< it3 >::type , F , N-4 >::type type; }; template struct result_of_unrolled_fold< StateRef , It0 , F , 3 > { typedef typename fold_lvalue_state< StateRef , It0 const , F >::type rest1; typedef typename result_of::next< It0 const >::type it1; typedef typename fold_lvalue_state< typename fold_lvalue_state< rest1 , it1 , F >::type , typename result_of::next< it1 const >::type const , F >::type type; }; template struct result_of_unrolled_fold< StateRef , It0 , F , 2 > : fold_lvalue_state< typename fold_lvalue_state< StateRef , It0 const , F >::type , typename result_of::next< It0 const >::type const , F > {}; template struct result_of_unrolled_fold< StateRef , It0 , F , 1 > : fold_lvalue_state< StateRef , It0 const , F > {}; template struct result_of_unrolled_fold< StateRef , It0 , F , 0 > { typedef StateRef type; }; template struct result_of_first_unrolledfold { typedef typename result_of_unrolled_fold< typename boost::result_of< F( StateRef, typename fusion::result_of::deref< It0 const>::type ) >::type , typename result_of::next< It0 const >::type , F , SeqSize-1 >::type type; }; template struct fold_impl { typedef typename result_of_first_unrolledfold< StateRef , typename result_of::begin::type , F , SeqSize >::type type; static type call(StateRef state, Seq& seq, F f) { typedef unrolled_fold< type , SeqSize > unrolled_impl; return unrolled_impl::call( state, fusion::begin(seq), f); } }; template struct fold_impl<0,StateRef,Seq,F> { typedef StateRef type; static StateRef call(StateRef state, Seq&, F) { return static_cast(state); } }; template struct result_of_fold : fold_impl< result_of::size::value , typename add_reference< typename add_const::type >::type , Seq , F > {}; } namespace result_of { template struct fold : detail::result_of_fold< Seq , State , F , traits::is_segmented::type::value > {}; } template inline typename result_of::fold< Seq , State const , F >::type fold(Seq& seq, State const& state, F f) { return result_of::fold::call( state, seq, f); } template inline typename result_of::fold< Seq const , State const , F >::type fold(Seq const& seq, State const& state, F f) { return result_of::fold::call( state, seq, f); } template inline typename result_of::fold< Seq , State const , F >::type fold(Seq& seq, State& state, F f) { return result_of::fold::call( state, seq, f); } template inline typename result_of::fold< Seq const , State const , F >::type fold(Seq const& seq, State& state, F f) { return result_of::fold::call( state, seq, f); } }}