make_expr.hpp

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

HPP
1,099
字号
                    )                                                                               \                  , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                                 \                )                                                                                   \            )                                                                                       \            BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT)             \        >::type const                                                                               \        BOOST_PP_TUPLE_ELEM(4, 0, DATA)(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a))           \        {                                                                                           \            return boost::proto::detail::make_expr_<                                                \                BOOST_PP_SEQ_FOR_EACH_I(                                                            \                    BOOST_PROTO_VARARG_TYPE_, ~                                                     \                  , BOOST_PP_SEQ_PUSH_FRONT(                                                        \                        BOOST_PROTO_SEQ_PUSH_FRONT(                                                 \                            BOOST_PP_TUPLE_ELEM(4, 2, DATA)                                         \                          , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))                                       \                        )                                                                           \                      , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                             \                    )                                                                               \                )                                                                                   \                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT)         \            >::call(                                                                                \                BOOST_PP_SEQ_ENUM(                                                                  \                    BOOST_PP_SEQ_FOR_EACH_I(                                                        \                        BOOST_PROTO_VARARG_AS_EXPR_, ~                                              \                      , BOOST_PP_SEQ_PUSH_FRONT(                                                    \                            BOOST_PROTO_SEQ_PUSH_FRONT(                                             \                                BOOST_PP_TUPLE_ELEM(4, 2, DATA)                                     \                              , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))                                   \                            )                                                                       \                          , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                         \                        )                                                                           \                    )                                                                               \                    BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_ARG_, a)                         \                )                                                                                   \            );                                                                                      \        }                                                                                           \        /**/    /// \code    /// BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(    ///     1    ///   , construct    ///   , boost::proto::default_domain    ///   , (boost::proto::tag::function)    ///   , ((op::construct)(typename)(int))    /// )    /// \endcode    #define BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(ARGCOUNT, NAME, DOMAIN, TAG, BOUNDARGS)            \        BOOST_PP_REPEAT_FROM_TO(                                                                    \            ARGCOUNT                                                                                \          , BOOST_PP_INC(ARGCOUNT)                                                                  \          , BOOST_PROTO_VARARG_FUN_                                                                 \          , (NAME, TAG, BOUNDARGS, DOMAIN)                                                          \        )\        /**/    /// \code    /// BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(    ///     construct    ///   , boost::proto::default_domain    ///   , (boost::proto::tag::function)    ///   , ((op::construct)(typename)(int))    /// )    /// \endcode    #define BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(NAME, DOMAIN, TAG, BOUNDARGS)               \        BOOST_PP_REPEAT(                                                                            \            BOOST_PP_SUB(BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), BOOST_PP_SEQ_SIZE(BOUNDARGS))         \          , BOOST_PROTO_VARARG_FUN_                                                                 \          , (NAME, TAG, BOUNDARGS, DOMAIN)                                                          \        )                                                                                           \        /**/        namespace detail        {            template<typename T, typename Domain>            struct protoify_            {                typedef                    typename boost::unwrap_reference<T>::type                unref_type;                typedef                    typename mpl::eval_if<                        boost::is_reference_wrapper<T>                      , proto::result_of::as_arg<unref_type, Domain>                      , proto::result_of::as_expr<unref_type, Domain>                    >::type                type;                static type call(T &t)                {                    return typename mpl::if_<                        is_reference_wrapper<T>                      , functional::as_arg<Domain>                      , functional::as_expr<Domain>                    >::type()(static_cast<unref_type &>(t));                }            };            template<typename T, typename Domain>            struct protoify_<T &, Domain>            {                typedef                    typename boost::unwrap_reference<T>::type                unref_type;                typedef                    typename proto::result_of::as_arg<unref_type, Domain>::type                type;                static type call(T &t)                {                    return functional::as_arg<Domain>()(static_cast<unref_type &>(t));                }            };            template<                typename Domain                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(                    BOOST_PROTO_MAX_ARITY                  , typename A                  , = default_domain BOOST_PP_INTERCEPT                )            >            struct deduce_domain_            {                typedef Domain type;            };            template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)>            struct deduce_domain_<                default_domain                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)            >              : deduce_domain_<                    typename domain_of<A0>::type                  , BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PROTO_MAX_ARITY, A)                >            {};            template<>            struct deduce_domain_<default_domain>            {                typedef default_domain type;            };            template<typename Tag, typename Domain, typename Sequence, std::size_t Size>            struct unpack_expr_            {};            template<typename Domain, typename Sequence>            struct unpack_expr_<tag::terminal, Domain, Sequence, 1u>            {                typedef                    typename add_const<                        typename fusion::BOOST_PROTO_FUSION_RESULT_OF::value_at_c<                            Sequence                          , 0                        >::type                    >::type                terminal_type;                typedef                    typename proto::detail::protoify_<                        terminal_type                      , Domain                    >::type                type;                static type const call(Sequence const &sequence)                {                    return proto::detail::protoify_<terminal_type, Domain>::call(fusion::BOOST_PROTO_FUSION_AT_C(0, sequence));                }            };            template<typename Sequence>            struct unpack_expr_<tag::terminal, deduce_domain, Sequence, 1u>              : unpack_expr_<tag::terminal, default_domain, Sequence, 1u>            {};            template<                typename Tag              , typename Domain                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(                    BOOST_PROTO_MAX_ARITY                  , typename A                  , = void BOOST_PP_INTERCEPT                )              , typename _ = void            >            struct make_expr_            {};            template<typename Domain, typename A>            struct make_expr_<tag::terminal, Domain, A                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, void BOOST_PP_INTERCEPT)>            {                typedef typename proto::detail::protoify_<A, Domain>::type type;                static type const call(typename add_reference<A>::type a)                {                    return proto::detail::protoify_<A, Domain>::call(a);                }            };            template<typename A>            struct make_expr_<tag::terminal, deduce_domain, A                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, void BOOST_PP_INTERCEPT)>              : make_expr_<tag::terminal, default_domain, A>            {};        #define BOOST_PP_ITERATION_PARAMS_1                                                         \            (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>, 1))               \            /**/        #include BOOST_PP_ITERATE()        }        namespace result_of        {            /// \brief Metafunction that computes the return type of the            /// \c make_expr() function, with a domain deduced from the            /// domains of the children.            ///            /// Use the <tt>result_of::make_expr\<\></tt> metafunction to            /// compute the return type of the \c make_expr() function.            ///            /// In this specialization, the domain is deduced from the            /// domains of the children types. (If            /// <tt>is_domain\<A0\>::::value</tt> is \c true, then another            /// specialization is selected.)            template<                typename Tag              , typename A0              , BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(                    BOOST_PROTO_MAX_ARITY                  , typename A                  , BOOST_PROTO_FOR_DOXYGEN_ONLY(= void) BOOST_PP_INTERCEPT                )              , typename Void1  BOOST_PROTO_FOR_DOXYGEN_ONLY(= void)              , typename Void2  BOOST_PROTO_FOR_DOXYGEN_ONLY(= void)            >            struct make_expr            {                /// Same as <tt>result_of::make_expr\<Tag, D, A0, ... AN\>::::type</tt>                /// where \c D is the deduced domain, which is calculated as follows:                ///                /// For each \c x in <tt>[0,N)</tt> (proceeding in order beginning with                /// <tt>x=0</tt>), if <tt>domain_of\<Ax\>::::type</tt> is not                /// \c default_domain, then \c D is <tt>domain_of\<Ax\>::::type</tt>.                /// Otherwise, \c D is \c default_domain.                typedef                    typename detail::make_expr_<                        Tag                      , deduce_domain                        BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)                    >::type                type;            };            /// \brief Metafunction that computes the return type of the            /// \c make_expr() function, within the specified domain.            ///            /// Use the <tt>result_of::make_expr\<\></tt> metafunction to compute            /// the return type of the \c make_expr() function.            template<                typename Tag              , typename Domain                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)            >            struct make_expr<                Tag              , Domain                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)              , typename Domain::proto_is_domain_

⌨️ 快捷键说明

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