⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fold.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 2 页
字号:
                    typedef                        typename fusion::BOOST_PROTO_FUSION_RESULT_OF::fold<                            BOOST_PROTO_AS_FUSION_SEQUENCE_TYPE(sequence)                          , state0                          , fun                        >::type                    type;                };                /// Let \c seq be <tt>when\<_, Sequence\>()(expr, state, visitor)</tt>, let                /// \c state0 be <tt>when\<_, State0\>()(expr, state, visitor)</tt>, and                /// let \c fun(visitor) be an object such that <tt>fun(visitor)(expr, state)</tt>                /// is equivalent to <tt>when\<_, Fun\>()(expr, state, visitor)</tt>. Then, this                /// function returns <tt>fusion::fold(seq, state0, fun(visitor))</tt>.                ///                /// \param expr The current expression                /// \param state The current state                /// \param visitor An arbitrary visitor                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    when<_, Sequence> sequence;                    detail::as_callable<Fun, Visitor> fun(visitor);                    return fusion::fold(                        BOOST_PROTO_AS_FUSION_SEQUENCE(sequence(expr, state, visitor))                      , when<_, State0>()(expr, state, visitor)                      , fun                    );                }            };            /// \brief A PrimitiveTransform that is the same as the            /// <tt>fold\<\></tt> transform, except that it folds            /// back-to-front instead of front-to-back. It uses            /// the \c _reverse callable PolymorphicFunctionObject            /// to create a <tt>fusion::reverse_view\<\></tt> of the            /// sequence before invoking <tt>fusion::fold\<\></tt>.            template<typename Sequence, typename State0, typename Fun>            struct reverse_fold              : fold<call<_reverse(Sequence)>, State0, Fun>            {};            // This specialization is only for improved compile-time performance            // in the commom case when the Sequence transform is \c proto::_.            //            /// INTERNAL ONLY            ///            template<typename State0, typename Fun>            struct fold<_, State0, Fun> : proto::callable            {                template<typename Sig>                struct result;                template<typename This, typename Expr, typename State, typename Visitor>                struct result<This(Expr, State, Visitor)>                {                    typedef                        typename detail::fold_impl<                            Fun                          , typename Expr::proto_base_expr                          , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type                          , Visitor                        >::type                    type;                };                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    typedef                        detail::fold_impl<                            Fun                          , typename Expr::proto_base_expr                          , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type                          , Visitor                        >                    impl;                    return impl::call(                        expr.proto_base()                      , when<_, State0>()(expr, state, visitor)                      , visitor                    );                }            };            // This specialization is only for improved compile-time performance            // in the commom case when the Sequence transform is \c proto::_.            //            /// INTERNAL ONLY            ///            template<typename State0, typename Fun>            struct reverse_fold<_, State0, Fun> : proto::callable            {                template<typename Sig>                struct result;                template<typename This, typename Expr, typename State, typename Visitor>                struct result<This(Expr, State, Visitor)>                {                    typedef                        typename detail::reverse_fold_impl<                            Fun                          , typename Expr::proto_base_expr                          , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type                          , Visitor                        >::type                    type;                };                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    typedef                        detail::reverse_fold_impl<                            Fun                          , typename Expr::proto_base_expr                          , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type                          , Visitor                        >                    impl;                    return impl::call(                        expr.proto_base()                      , when<_, State0>()(expr, state, visitor)                      , visitor                    );                }            };        }        /// INTERNAL ONLY        ///        template<typename Sequence, typename State, typename Fun>        struct is_callable<transform::fold<Sequence, State, Fun> >          : mpl::true_        {};        /// INTERNAL ONLY        ///        template<typename Sequence, typename State, typename Fun>        struct is_callable<transform::reverse_fold<Sequence, State, Fun> >          : mpl::true_        {};    }}    #endif#else    #define N BOOST_PP_ITERATION()            template<typename Fun, typename Expr, typename state0, typename Visitor>            struct fold_impl<Fun, Expr, state0, Visitor, N>            {                BOOST_PP_REPEAT(N, BOOST_PROTO_FOLD_STATE_TYPE, N)                typedef BOOST_PP_CAT(state, N) type;                static type call(Expr const &expr, state0 const &s0, Visitor &visitor)                {                    BOOST_PP_REPEAT(N, BOOST_PROTO_FOLD_STATE, N)                    return BOOST_PP_CAT(s, N);                }            };            template<typename Fun, typename Expr, typename BOOST_PP_CAT(state, N), typename Visitor>            struct reverse_fold_impl<Fun, Expr, BOOST_PP_CAT(state, N), Visitor, N>            {                BOOST_PP_REPEAT(N, BOOST_PROTO_REVERSE_FOLD_STATE_TYPE, N)                typedef state0 type;                static type call(Expr const &expr, BOOST_PP_CAT(state, N) const &BOOST_PP_CAT(s, N), Visitor &visitor)                {                    BOOST_PP_REPEAT(N, BOOST_PROTO_REVERSE_FOLD_STATE, N)                    return s0;                }            };    #undef N#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -