diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index c8eaf360..c6bc2eeb 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -57,39 +57,11 @@ namespace boost { namespace fusion template struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) { - template + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result - call(State const& state,It0 const& it0,F f) + call_3(State3 const& state3,It3 const& it3,F& f) { - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - It1; - It1 it1 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0); - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It1 - >::type - It2; - It2 it2 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1); - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It2 - >::type - It3; - It3 it3 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it2); - - typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)::type State1; - State1 const state1=f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); - - typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)::type State2; - State2 const state2=f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)); - - typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)::type State3; - State3 const state3=f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)); - return BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< Result , N-4 @@ -98,54 +70,95 @@ namespace boost { namespace fusion fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it3), f); } - }; - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { + return call_3( + f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)), + fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it2), + f); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), + fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), + f); + } + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - It1; - It1 it1 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0); - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It1 - >::type - It2; - It2 it2 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1); - - typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)::type State1; - State1 const state1=f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); - - typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)::type State2; - State2 const state2=f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)); + return call_1( + f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), + fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), + f); + } + }; + template + struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) + { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { return f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), + fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), + f); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call(State const& state,It0 const& it0,F f) + { + return call_1( + f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), + fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), + f); + } }; template struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)); + } + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)::type State1; - State1 const state1=f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); - - return f( - state1, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM( - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0))); + return call_1( + f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), + fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), + f); } }; diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp index e717fba8..9b27815b 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp @@ -23,35 +23,11 @@ namespace boost { namespace fusion template struct unrolled_fold { - template + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result - call(State const& state,It0 const& it0,F f) + call_3(State3 const& state3,It3 const& it3,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 @@ -60,47 +36,87 @@ namespace boost { namespace fusion fusion::next(it3), f); } - }; - template - struct unrolled_fold - { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { + return call_3( + f(state2,fusion::deref(it2)), + fusion::next(it2), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,fusion::deref(it1)), + fusion::next(it1), + f); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED 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 call_1( + f(state,fusion::deref(it0)), + fusion::next(it0), + f); + } + }; + template + struct unrolled_fold + { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { return f(state2,fusion::deref(it2)); } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,fusion::deref(it1)), + fusion::next(it1), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call(State const& state,It0 const& it0,F f) + { + return call_1( + f(state,fusion::deref(it0)), + fusion::next(it0), + f); + } }; template struct unrolled_fold { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return f(state1,fusion::deref(it1)); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED 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))); + return call_1( + f(state,fusion::deref(it0)), + fusion::next(it0), + f); } }; template diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp index f936acb1..b86847ee 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp @@ -22,35 +22,11 @@ namespace boost { namespace fusion template struct unrolled_iter_fold { - template + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result - call(State const& state,It0 const& it0,F f) + call_3(State3 const& state3,It3 const& it3,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 iter_fold_lvalue_state::type State1; - State1 const state1=f(state,it0); - typedef typename iter_fold_lvalue_state::type State2; - State2 const state2=f(state1,it1); - typedef typename iter_fold_lvalue_state::type State3; - State3 const state3=f(state2,it2); return unrolled_iter_fold< Result , N-4 @@ -59,47 +35,87 @@ namespace boost { namespace fusion fusion::next(it3), f); } - }; - template - struct unrolled_iter_fold - { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { + return call_3( + f(state2,it2), + fusion::next(it2), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,it1), + fusion::next(it1), + f); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED 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 iter_fold_lvalue_state::type State1; - State1 const state1=f(state,it0); - typedef typename iter_fold_lvalue_state::type State2; - State2 const state2=f(state1,it1); + return call_1( + f(state,it0), + fusion::next(it0), + f); + } + }; + template + struct unrolled_iter_fold + { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { return f(state2,it2); } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,it1), + fusion::next(it1), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call(State const& state,It0 const& it0,F f) + { + return call_1( + f(state,it0), + fusion::next(it0), + f); + } }; template struct unrolled_iter_fold { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return f(state1,it1); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename iter_fold_lvalue_state::type State1; - State1 const state1=f(state,it0); - return f( - state1, - fusion::next(it0)); + return call_1( + f(state,it0), + fusion::next(it0), + f); } }; template diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp index 4413ee45..95122c8e 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp @@ -22,35 +22,11 @@ namespace boost { namespace fusion template struct unrolled_reverse_fold { - template + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result - call(State const& state,It0 const& it0,F f) + call_3(State3 const& state3,It3 const& it3,F& f) { - typedef typename - result_of::prior< - It0 const - >::type - It1; - It1 it1 = fusion::prior(it0); - typedef typename - result_of::prior< - It1 - >::type - It2; - It2 it2 = fusion::prior(it1); - typedef typename - result_of::prior< - It2 - >::type - It3; - It3 it3 = fusion::prior(it2); - typedef typename reverse_fold_lvalue_state::type State1; - State1 const state1=f(state,fusion::deref(it0)); - typedef typename reverse_fold_lvalue_state::type State2; - State2 const state2=f(state1,fusion::deref(it1)); - typedef typename reverse_fold_lvalue_state::type State3; - State3 const state3=f(state2,fusion::deref(it2)); return unrolled_reverse_fold< Result , N-4 @@ -59,47 +35,87 @@ namespace boost { namespace fusion fusion::prior(it3), f); } - }; - template - struct unrolled_reverse_fold - { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { + return call_3( + f(state2,fusion::deref(it2)), + fusion::prior(it2), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,fusion::deref(it1)), + fusion::prior(it1), + f); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename - result_of::prior< - It0 const - >::type - It1; - It1 it1 = fusion::prior(it0); - typedef typename - result_of::prior< - It1 - >::type - It2; - It2 it2 = fusion::prior(it1); - typedef typename reverse_fold_lvalue_state::type State1; - State1 const state1=f(state,fusion::deref(it0)); - typedef typename reverse_fold_lvalue_state::type State2; - State2 const state2=f(state1,fusion::deref(it1)); + return call_1( + f(state,fusion::deref(it0)), + fusion::prior(it0), + f); + } + }; + template + struct unrolled_reverse_fold + { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { return f(state2,fusion::deref(it2)); } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,fusion::deref(it1)), + fusion::prior(it1), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call(State const& state,It0 const& it0,F f) + { + return call_1( + f(state,fusion::deref(it0)), + fusion::prior(it0), + f); + } }; template struct unrolled_reverse_fold { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return f(state1,fusion::deref(it1)); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename reverse_fold_lvalue_state::type State1; - State1 const state1=f(state,fusion::deref(it0)); - return f( - state1, - fusion::deref( fusion::prior(it0))); + return call_1( + f(state,fusion::deref(it0)), + fusion::prior(it0), + f); } }; template diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp index e3020e26..3dc434fc 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp @@ -22,35 +22,11 @@ namespace boost { namespace fusion template struct unrolled_reverse_iter_fold { - template + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result - call(State const& state,It0 const& it0,F f) + call_3(State3 const& state3,It3 const& it3,F& f) { - typedef typename - result_of::prior< - It0 const - >::type - It1; - It1 it1 = fusion::prior(it0); - typedef typename - result_of::prior< - It1 - >::type - It2; - It2 it2 = fusion::prior(it1); - typedef typename - result_of::prior< - It2 - >::type - It3; - It3 it3 = fusion::prior(it2); - typedef typename reverse_iter_fold_lvalue_state::type State1; - State1 const state1=f(state,it0); - typedef typename reverse_iter_fold_lvalue_state::type State2; - State2 const state2=f(state1,it1); - typedef typename reverse_iter_fold_lvalue_state::type State3; - State3 const state3=f(state2,it2); return unrolled_reverse_iter_fold< Result , N-4 @@ -59,47 +35,87 @@ namespace boost { namespace fusion fusion::prior(it3), f); } - }; - template - struct unrolled_reverse_iter_fold - { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { + return call_3( + f(state2,it2), + fusion::prior(it2), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,it1), + fusion::prior(it1), + f); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename - result_of::prior< - It0 const - >::type - It1; - It1 it1 = fusion::prior(it0); - typedef typename - result_of::prior< - It1 - >::type - It2; - It2 it2 = fusion::prior(it1); - typedef typename reverse_iter_fold_lvalue_state::type State1; - State1 const state1=f(state,it0); - typedef typename reverse_iter_fold_lvalue_state::type State2; - State2 const state2=f(state1,it1); + return call_1( + f(state,it0), + fusion::prior(it0), + f); + } + }; + template + struct unrolled_reverse_iter_fold + { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_2(State2 const& state2,It2 const& it2,F& f) + { return f(state2,it2); } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return call_2( + f(state1,it1), + fusion::prior(it1), + f); + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call(State const& state,It0 const& it0,F f) + { + return call_1( + f(state,it0), + fusion::prior(it0), + f); + } }; template struct unrolled_reverse_iter_fold { + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static Result + call_1(State1 const& state1,It1 const& it1,F& f) + { + return f(state1,it1); + } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static Result call(State const& state,It0 const& it0,F f) { - typedef typename reverse_iter_fold_lvalue_state::type State1; - State1 const state1=f(state,it0); - return f( - state1, - fusion::prior(it0)); + return call_1( + f(state,it0), + fusion::prior(it0), + f); } }; template