default.hpp

来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 395 行 · 第 1/2 页

HPP
395
字号
            BOOST_PROTO_BINARY_OP_RESULT(>, proto::tag::greater)            BOOST_PROTO_BINARY_OP_RESULT(<=, proto::tag::less_equal)            BOOST_PROTO_BINARY_OP_RESULT(>=, proto::tag::greater_equal)            BOOST_PROTO_BINARY_OP_RESULT(==, proto::tag::equal_to)            BOOST_PROTO_BINARY_OP_RESULT(!=, proto::tag::not_equal_to)            BOOST_PROTO_BINARY_OP_RESULT(||, proto::tag::logical_or)            BOOST_PROTO_BINARY_OP_RESULT(&&, proto::tag::logical_and)            BOOST_PROTO_BINARY_OP_RESULT(&, proto::tag::bitwise_and)            BOOST_PROTO_BINARY_OP_RESULT(|, proto::tag::bitwise_or)            BOOST_PROTO_BINARY_OP_RESULT(^, proto::tag::bitwise_xor)            BOOST_PROTO_BINARY_OP_RESULT(->*, proto::tag::mem_ptr)            BOOST_PROTO_BINARY_OP_RESULT(=, proto::tag::assign)            BOOST_PROTO_BINARY_OP_RESULT(<<=, proto::tag::shift_left_assign)            BOOST_PROTO_BINARY_OP_RESULT(>>=, proto::tag::shift_right_assign)            BOOST_PROTO_BINARY_OP_RESULT(*=, proto::tag::multiplies_assign)            BOOST_PROTO_BINARY_OP_RESULT(/=, proto::tag::divides_assign)            BOOST_PROTO_BINARY_OP_RESULT(%=, proto::tag::modulus_assign)            BOOST_PROTO_BINARY_OP_RESULT(+=, proto::tag::plus_assign)            BOOST_PROTO_BINARY_OP_RESULT(-=, proto::tag::minus_assign)            BOOST_PROTO_BINARY_OP_RESULT(&=, proto::tag::bitwise_and_assign)            BOOST_PROTO_BINARY_OP_RESULT(|=, proto::tag::bitwise_or_assign)            BOOST_PROTO_BINARY_OP_RESULT(^=, proto::tag::bitwise_xor_assign)        #undef BOOST_PROTO_UNARY_OP_RESULT        #undef BOOST_PROTO_BINARY_OP_RESULT            template<typename Expr, typename Context>            struct default_eval<Expr, Context, proto::tag::terminal, 0>            {                typedef                    typename mpl::if_<                        is_const<Expr>                      , typename proto::result_of::arg<Expr>::const_reference                      , typename proto::result_of::arg<Expr>::reference                    >::type                result_type;                result_type operator ()(Expr &expr, Context &) const                {                    return proto::arg(expr);                }            };            // Handle post-increment specially.            template<typename Expr, typename Context>            struct default_eval<Expr, Context, proto::tag::post_inc, 1>            {            private:                typedef typename proto::result_of::arg_c<Expr, 0>::type e0;                typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;            public:                BOOST_PROTO_DECLTYPE_(proto::detail::make<r0>() ++, result_type)                result_type operator ()(Expr &expr, Context &ctx) const                {                    return proto::eval(proto::arg_c<0>(expr), ctx) ++;                }            };            // Handle post-decrement specially.            template<typename Expr, typename Context>            struct default_eval<Expr, Context, proto::tag::post_dec, 1>            {            private:                typedef typename proto::result_of::arg_c<Expr, 0>::type e0;                typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;            public:                BOOST_PROTO_DECLTYPE_(proto::detail::make<r0>() --, result_type)                result_type operator ()(Expr &expr, Context &ctx) const                {                    return proto::eval(proto::arg_c<0>(expr), ctx) --;                }            };            // Handle subscript specially.            template<typename Expr, typename Context>            struct default_eval<Expr, Context, proto::tag::subscript, 2>            {            private:                typedef typename proto::result_of::arg_c<Expr, 0>::type e0;                typedef typename proto::result_of::arg_c<Expr, 1>::type e1;                typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;                typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;            public:                BOOST_PROTO_DECLTYPE_(proto::detail::make<r0>()[proto::detail::make<r1>()], result_type)                result_type operator ()(Expr &expr, Context &ctx) const                {                    return proto::eval(proto::arg_c<0>(expr), ctx)[proto::eval(proto::arg_c<1>(expr), ctx)];                }            };            // Handle if_else_ specially.            template<typename Expr, typename Context>            struct default_eval<Expr, Context, proto::tag::if_else_, 3>            {            private:                typedef typename proto::result_of::arg_c<Expr, 0>::type e0;                typedef typename proto::result_of::arg_c<Expr, 1>::type e1;                typedef typename proto::result_of::arg_c<Expr, 2>::type e2;                typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;                typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;                typedef typename proto::result_of::eval<UNREF(e2), Context>::type r2;            public:                BOOST_PROTO_DECLTYPE_(                    proto::detail::make<r0>()                  ? proto::detail::make<r1>()                  : proto::detail::make<r2>()                  , result_type                )                result_type operator ()(Expr &expr, Context &ctx) const                {                    return proto::eval(proto::arg_c<0>(expr), ctx)                         ? proto::eval(proto::arg_c<1>(expr), ctx)                         : proto::eval(proto::arg_c<2>(expr), ctx);                }            };            // Handle comma specially.            template<typename Expr, typename Context>            struct default_eval<Expr, Context, proto::tag::comma, 2>            {            private:                typedef typename proto::result_of::arg_c<Expr, 0>::type e0;                typedef typename proto::result_of::arg_c<Expr, 1>::type e1;                typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;                typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;            public:                typedef typename proto::detail::comma_result<r0, r1>::type result_type;                result_type operator ()(Expr &expr, Context &ctx) const                {                    return proto::eval(proto::arg_c<0>(expr), ctx), proto::eval(proto::arg_c<1>(expr), ctx);                }            };            // Handle function specially            #define EVAL_TYPE(Z, N, DATA)                                                           \                typename proto::result_of::eval<                                                    \                    typename remove_reference<typename proto::result_of::arg_c<DATA, N>::type>::type\                  , Context                                                                         \                >::type            #define EVAL(Z, N, DATA)                                                                \                proto::eval(proto::arg_c<N>(DATA), context)            #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/context/default.hpp>))            #include BOOST_PP_ITERATE()            #undef EVAL_TYPE            #undef EVAL            /// default_context            ///            struct default_context            {                /// default_context::eval                ///                template<typename Expr, typename ThisContext = default_context const>                struct eval                  : default_eval<Expr, ThisContext>                {};            };        } // namespace context    }} // namespace boost::proto    #undef UNREF    #endif#else    #define N BOOST_PP_ITERATION()        template<typename Expr, typename Context>        struct default_eval<Expr, Context, proto::tag::function, N>        {            typedef                typename proto::detail::result_of_fixup<EVAL_TYPE(~, 0, Expr)>::type            function_type;            typedef                typename boost::result_of<                    function_type(BOOST_PP_ENUM_SHIFTED(BOOST_PP_MAX(N, 1), EVAL_TYPE, Expr))                >::type            result_type;            result_type operator ()(Expr &expr, Context &context) const            {                return EVAL(~, 0, expr)(BOOST_PP_ENUM_SHIFTED(BOOST_PP_MAX(N, 1), EVAL, expr));            }        };    #undef N#endif

⌨️ 快捷键说明

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