/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2006 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt Copyright (c) 2015 Kohei Takahashi 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) ==============================================================================*/ #include #ifdef BOOST_FUSION_REVERSE_FOLD # ifdef BOOST_FUSION_ITER_FOLD # define BOOST_FUSION_FOLD_NAME reverse_iter_fold # else # define BOOST_FUSION_FOLD_NAME reverse_fold # endif # define BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION end # define BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION prior # define BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(IT) \ typename fusion::result_of::prior::type # define BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM(IT) fusion::prior(IT) #else # ifdef BOOST_FUSION_ITER_FOLD # define BOOST_FUSION_FOLD_NAME iter_fold # else # define BOOST_FUSION_FOLD_NAME fold # endif # define BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION begin # define BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION next # define BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(IT) IT # define BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM(IT) IT #endif #ifdef BOOST_FUSION_ITER_FOLD # define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(IT) IT& # define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(IT) IT #else # define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(IT) \ typename fusion::result_of::deref::type # define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(IT) fusion::deref(IT) #endif namespace boost { namespace fusion { namespace detail { template struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME) {}; template struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<0,It,State,F , typename boost::enable_if_has_type::type> { typedef typename State::type type; }; template struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)::type::type >::type> : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< SeqSize-1 , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type , boost::result_of< F( typename add_reference::type>::type, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) > , F > {}; template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< 0 , It , State , F >::type BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<0>, It const&, typename State::type state, F&) { return state; } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename lazy_enable_if_c< SeqSize != 0 , BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< SeqSize , It , State , F > >::type BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_, It const& it, typename State::type state, F& f) { return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type , boost::result_of< F( typename add_reference::type>::type, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) > , F >( mpl::int_() , fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it) , f(state, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it)) , f ); } template::value , bool = traits::is_segmented::value> struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) {}; template struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< result_of::size::value , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type ) , add_reference::type> , F > {}; template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)::type BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F& f) { return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type ) , add_reference::type> , F >( typename result_of::size::type() , BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq) ) , state , f ); } } namespace result_of { template struct BOOST_FUSION_FOLD_NAME : detail::BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) {}; } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq , State const , F >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State const& state, F f) { return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq const , State const , F >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State const& state, F f) { return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq , State const , F >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) { return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq const , State const , F >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) { return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } }} #undef BOOST_FUSION_FOLD_NAME #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION #undef BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM