Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/fusion/algorithm/iteration/detail/fold.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003     Copyright (c) 2006 Dan Marsden
0004     Copyright (c) 2009-2010 Christopher Schmidt
0005     Copyright (c) 2015 Kohei Takahashi
0006 
0007     Distributed under the Boost Software License, Version 1.0. (See accompanying
0008     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 ==============================================================================*/
0010 #include <boost/preprocessor/cat.hpp>
0011 
0012 #define FUSION_HASH 0013 
0014 ">#
0015 
0016 #ifdef BOOST_FUSION_REVERSE_FOLD
0017 #   ifdef BOOST_FUSION_ITER_FOLD
0018 #       define BOOST_FUSION_FOLD_NAME reverse_iter_fold
0019 #   else
0020 #       define BOOST_FUSION_FOLD_NAME reverse_fold
0021 #   endif
0022 
0023 #   define BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION end
0024 #   define BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION prior
0025 #   define BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(IT)                   \
0026         typename fusion::result_of::prior<IT>::type
0027 #   define BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM(IT) fusion::prior(IT)
0028 #else
0029 #   ifdef BOOST_FUSION_ITER_FOLD
0030 #       define BOOST_FUSION_FOLD_NAME iter_fold
0031 #   else
0032 #       define BOOST_FUSION_FOLD_NAME fold
0033 #   endif
0034 
0035 #   define BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION begin
0036 #   define BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION next
0037 #   define BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(IT) IT
0038 #   define BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM(IT) IT
0039 #endif
0040 #ifdef BOOST_FUSION_ITER_FOLD
0041 #   define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(IT) IT&
0042 #   define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(IT) IT
0043 #else
0044 #   define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(IT)                  \
0045         typename fusion::result_of::deref<IT>::type
0046 #   define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(IT) fusion::deref(IT)
0047 #endif
0048 
0049 #if (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
0050 FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500)
0051 FUSION_HASH     define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void
0052 FUSION_HASH else
0053 FUSION_HASH     define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type
0054 FUSION_HASH endif
0055 #else
0056 #   if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
0057 #       define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void
0058 #   else
0059 #       define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type
0060 #   endif
0061 #endif
0062 
0063 namespace boost { namespace fusion
0064 {
0065     namespace detail
0066     {
0067         template<int SeqSize, typename It, typename State, typename F, typename = void
0068 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0069 FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500)
0070 #endif
0071 #if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \
0072     (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
0073           // Dirty hack: those compilers cannot choose exactly one partial specialization.
0074           , bool = SeqSize == 0
0075 #endif
0076 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0077 FUSION_HASH endif
0078 #endif
0079         >
0080         struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)
0081         {};
0082 
0083         template<typename It, typename State, typename F>
0084         struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<0,It,State,F
0085           , typename boost::enable_if_has_type<BOOST_FUSION_FOLD_IMPL_ENABLER(State)>::type
0086 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0087 FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500)
0088 #endif
0089 #if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \
0090     (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
0091           , true
0092 #endif
0093 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0094 FUSION_HASH endif
0095 #endif
0096           >
0097         {
0098             typedef typename State::type type;
0099         };
0100 
0101         template<int SeqSize, typename It, typename State, typename F>
0102         struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<SeqSize,It,State,F
0103           , typename boost::enable_if_has_type<
0104 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0105 FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, >= 1500)
0106 #endif
0107 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1500) || \
0108     (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
0109                 // Following SFINAE enables to avoid MSVC 9's partial specialization
0110                 // ambiguous bug but MSVC 8 don't compile, and moreover MSVC 8 style
0111                 // workaround won't work with MSVC 9.
0112                 typename boost::disable_if_c<SeqSize == 0, State>::type::type
0113 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0114 FUSION_HASH else
0115                 BOOST_FUSION_FOLD_IMPL_ENABLER(State)
0116 #endif
0117 #else
0118                 BOOST_FUSION_FOLD_IMPL_ENABLER(State)
0119 #endif
0120 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0121 FUSION_HASH endif
0122 #endif
0123             >::type
0124 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0125 FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500)
0126 #endif
0127 #if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \
0128     (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
0129           , false
0130 #endif
0131 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
0132 FUSION_HASH endif
0133 #endif
0134           >
0135           : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<
0136                 SeqSize-1
0137               , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type
0138               , boost::result_of<
0139                     F(
0140                         typename add_reference<typename State::type>::type,
0141                         BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const)
0142                     )
0143                 >
0144               , F
0145             >
0146         {};
0147 
0148         template<typename It, typename State, typename F>
0149         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0150         inline typename BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<
0151             0
0152           , It
0153           , State
0154           , F
0155         >::type
0156         BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<0>, It const&, typename State::type state, F&)
0157         {
0158             return state;
0159         }
0160 
0161         template<typename It, typename State, typename F, int SeqSize>
0162         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0163         inline typename lazy_enable_if_c<
0164             SeqSize != 0
0165           , BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<
0166                 SeqSize
0167               , It
0168               , State
0169               , F
0170             >
0171         >::type
0172         BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<SeqSize>, It const& it, typename State::type state, F& f)
0173         {
0174             return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)<
0175                 typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type
0176               , boost::result_of<
0177                     F(
0178                         typename add_reference<typename State::type>::type,
0179                         BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const)
0180                     )
0181                 >
0182               , F
0183             >(
0184                 mpl::int_<SeqSize-1>()
0185               , fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it)
0186               , f(state, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it))
0187               , f
0188             );
0189         }
0190 
0191         template<typename Seq, typename State, typename F
0192           , bool = traits::is_sequence<Seq>::value
0193           , bool = traits::is_segmented<Seq>::value>
0194         struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)
0195         {};
0196 
0197         template<typename Seq, typename State, typename F>
0198         struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)<Seq, State, F, true, false>
0199           : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<
0200                 result_of::size<Seq>::value
0201               , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(
0202                     typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type
0203                 )
0204               , add_reference<State>
0205               , F
0206             >
0207         {};
0208 
0209         template<typename Seq, typename State, typename F>
0210         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0211         inline typename BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)<Seq, State, F>::type
0212         BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F& f)
0213         {
0214             return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)<
0215                 BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(
0216                     typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type
0217                 )
0218               , add_reference<State>
0219               , F
0220             >(
0221                 typename result_of::size<Seq>::type()
0222               , BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM(
0223                     fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq)
0224                 )
0225               , state
0226               , f
0227             );
0228         }
0229     }
0230 
0231     namespace result_of
0232     {
0233         template<typename Seq, typename State, typename F>
0234         struct BOOST_FUSION_FOLD_NAME
0235           : detail::BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)<Seq, State, F>
0236         {};
0237     }
0238 
0239     template<typename Seq, typename State, typename F>
0240     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0241     inline typename result_of::BOOST_FUSION_FOLD_NAME<
0242         Seq
0243       , State const
0244       , F
0245     >::type
0246     BOOST_FUSION_FOLD_NAME(Seq& seq, State const& state, F f)
0247     {
0248         return detail::BOOST_FUSION_FOLD_NAME<Seq, State const, F>(seq, state, f);
0249     }
0250 
0251     template<typename Seq, typename State, typename F>
0252     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0253     inline typename result_of::BOOST_FUSION_FOLD_NAME<
0254         Seq const
0255       , State const
0256       , F
0257     >::type
0258     BOOST_FUSION_FOLD_NAME(Seq const& seq, State const& state, F f)
0259     {
0260         return detail::BOOST_FUSION_FOLD_NAME<Seq const, State const, F>(seq, state, f);
0261     }
0262 
0263     template<typename Seq, typename State, typename F>
0264     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0265     inline typename result_of::BOOST_FUSION_FOLD_NAME<
0266         Seq
0267       , State
0268       , F
0269     >::type
0270     BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f)
0271     {
0272         return detail::BOOST_FUSION_FOLD_NAME<Seq, State, F>(seq, state, f);
0273     }
0274 
0275     template<typename Seq, typename State, typename F>
0276     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0277     inline typename result_of::BOOST_FUSION_FOLD_NAME<
0278         Seq const
0279       , State
0280       , F
0281     >::type
0282     BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f)
0283     {
0284         return detail::BOOST_FUSION_FOLD_NAME<Seq const, State, F>(seq, state, f);
0285     }
0286 }}
0287 
0288 #undef BOOST_FUSION_FOLD_NAME
0289 #undef BOOST_FUSION_FOLD_IMPL_ENABLER
0290 #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION
0291 #undef BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION
0292 #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM
0293 #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM
0294 #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM
0295 #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM
0296 #undef FUSION_HASH