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

📄 traits.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 5 页
字号:
            /// The <tt>as_arg\<\></tt> metafunction turns types into Proto types, if            /// they are not already, by making them Proto terminals held by reference.            /// Types which are already Proto types are wrapped in <tt>proto::ref_\<\></tt>.            ///            /// This specialization is selected when the type is already a Proto type.            /// The result type <tt>as_arg\<T, Domain\>::::type</tt> is            /// <tt>proto::ref_\<T\></tt>.            template<typename T, typename Domain>            struct as_arg<T, Domain, typename T::proto_is_expr_>            {                typedef ref_<T> type;                /// INTERNAL ONLY                ///                template<typename T2>                static type call(T2 &t)                {                    return type::make(t);                }            };            /// \brief A metafunction that returns the type of the Nth child            /// of a Proto expression, where N is an MPL Integral Constant.            ///            /// <tt>result_of::arg\<Expr, N\></tt> is equivalent to            /// <tt>result_of::arg_c\<Expr, N::value\></tt>.            template<typename Expr, typename N  BOOST_PROTO_FOR_DOXYGEN_ONLY(= mpl::long_<0>) >            struct arg              : arg_c<Expr, N::value>            {};            // TODO left<> and right<> force the instantiation of Expr.            // Couldn't we partially specialize them on proto::expr< T, A >            // and ref_< proto::expr< T, A > > and return A::arg0 / A::arg1?            /// \brief A metafunction that returns the type of the left child            /// of a binary Proto expression.            ///            /// <tt>result_of::left\<Expr\></tt> is equivalent to            /// <tt>result_of::arg_c\<Expr, 0\></tt>.            template<typename Expr>            struct left            {                typedef typename Expr::proto_arg0 wrapped_type;                typedef typename unref<wrapped_type>::type type;                typedef typename unref<wrapped_type>::reference reference;                typedef typename unref<wrapped_type>::const_reference const_reference;            };            /// \brief A metafunction that returns the type of the right child            /// of a binary Proto expression.            ///            /// <tt>result_of::right\<Expr\></tt> is equivalent to            /// <tt>result_of::arg_c\<Expr, 1\></tt>.            template<typename Expr>            struct right            {                typedef typename Expr::proto_arg1 wrapped_type;                typedef typename unref<wrapped_type>::type type;                typedef typename unref<wrapped_type>::reference reference;                typedef typename unref<wrapped_type>::const_reference const_reference;            };        } // namespace result_of        namespace op        {            /// \brief A metafunction for generating terminal expression types,            /// a grammar element for matching terminal expressions, and a            /// PrimitiveTransform that returns the current expression unchanged.            template<typename T>            struct terminal            {                typedef proto::expr<proto::tag::terminal, args0<T> > type;                typedef type proto_base_expr;                template<typename Sig>                struct result;                template<typename This, typename Expr, typename State, typename Visitor>                struct result<This(Expr, State, Visitor)>                {                    typedef Expr type;                };                /// \param expr The current expression                /// \pre <tt>matches\<Expr, terminal\<T\> \>::::value</tt> is \c true.                /// \return \c expr                /// \throw nothrow                template<typename Expr, typename State, typename Visitor>                Expr const &operator ()(Expr const &expr, State const &, Visitor &) const                {                    return expr;                }                /// INTERNAL ONLY                typedef proto::tag::terminal proto_tag;                /// INTERNAL ONLY                typedef T proto_arg0;            };            /// \brief A metafunction for generating ternary conditional expression types,            /// a grammar element for matching ternary conditional expressions, and a            /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>            /// transform.            template<typename T, typename U, typename V>            struct if_else_            {                typedef proto::expr<proto::tag::if_else_, args3<T, U, V> > type;                typedef type proto_base_expr;                template<typename Sig>                struct result                {                    typedef                        typename pass_through<if_else_>::template result<Sig>::type                    type;                };                /// \param expr The current expression                /// \param state The current state                /// \param visitor An arbitrary visitor                /// \pre <tt>matches\<Expr, if_else_\<T,U,V\> \>::::value</tt> is \c true.                /// \return <tt>pass_through\<if_else_\<T,U,V\> \>()(expr, state, visitor)</tt>                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    return pass_through<if_else_>()(expr, state, visitor);                }                /// INTERNAL ONLY                typedef proto::tag::if_else_ proto_tag;                /// INTERNAL ONLY                typedef T proto_arg0;                /// INTERNAL ONLY                typedef U proto_arg1;                /// INTERNAL ONLY                typedef V proto_arg2;            };            /// \brief A metafunction for generating unary expression types with a            /// specified tag type,            /// a grammar element for matching unary expressions, and a            /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>            /// transform.            ///            /// Use <tt>unary_expr\<_, _\></tt> as a grammar element to match any            /// unary expression.            template<typename Tag, typename T>            struct unary_expr            {                typedef proto::expr<Tag, args1<T> > type;                typedef type proto_base_expr;                template<typename Sig>                struct result                {                    typedef                        typename pass_through<unary_expr>::template result<Sig>::type                    type;                };                /// \param expr The current expression                /// \param state The current state                /// \param visitor An arbitrary visitor                /// \pre <tt>matches\<Expr, unary_expr\<Tag, T\> \>::::value</tt> is \c true.                /// \return <tt>pass_through\<unary_expr\<Tag, T\> \>()(expr, state, visitor)</tt>                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    return pass_through<unary_expr>()(expr, state, visitor);                }                /// INTERNAL ONLY                typedef Tag proto_tag;                /// INTERNAL ONLY                typedef T proto_arg0;            };            /// \brief A metafunction for generating binary expression types with a            /// specified tag type,            /// a grammar element for matching binary expressions, and a            /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>            /// transform.            ///            /// Use <tt>binary_expr\<_, _, _\></tt> as a grammar element to match any            /// binary expression.            template<typename Tag, typename T, typename U>            struct binary_expr            {                typedef proto::expr<Tag, args2<T, U> > type;                typedef type proto_base_expr;                template<typename Sig>                struct result                {                    typedef                        typename pass_through<binary_expr>::template result<Sig>::type                    type;                };                /// \param expr The current expression                /// \param state The current state                /// \param visitor An arbitrary visitor                /// \pre <tt>matches\<Expr, binary_expr\<Tag,T,U\> \>::::value</tt> is \c true.                /// \return <tt>pass_through\<binary_expr\<Tag,T,U\> \>()(expr, state, visitor)</tt>                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    return pass_through<binary_expr>()(expr, state, visitor);                }                /// INTERNAL ONLY                typedef Tag proto_tag;                /// INTERNAL ONLY                typedef T proto_arg0;                /// INTERNAL ONLY                typedef U proto_arg1;            };            /// \brief A metafunction for generating unary plus expression types,            /// a grammar element for matching unary plus expressions, and a            /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>            /// transform.            template<typename T>            struct posit            {                typedef proto::expr<proto::tag::posit, args1<T> > type;                typedef type proto_base_expr;                template<typename Sig>                struct result                {                    typedef                        typename pass_through<posit>::template result<Sig>::type                    type;                };                /// \param expr The current expression                /// \param state The current state                /// \param visitor An arbitrary visitor                /// \pre <tt>matches\<Expr, posit\<T\> \>::::value</tt> is \c true.                /// \return <tt>pass_through\<posit\<T\> \>()(expr, state, visitor)</tt>                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    return pass_through<posit>()(expr, state, visitor);                }                /// INTERNAL ONLY                typedef proto::tag::posit proto_tag;                /// INTERNAL ONLY                typedef T proto_arg0;            };            /// \brief A metafunction for generating unary minus expression types,            /// a grammar element for matching unary minus expressions, and a            /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>            /// transform.            template<typename T>            struct negate            {                typedef proto::expr<proto::tag::negate, args1<T> > type;                typedef type proto_base_expr;                template<typename Sig>                struct result                {                    typedef                        typename pass_through<negate>::template result<Sig>::type                    type;                };                /// \param expr The current expression                /// \param state The current state                /// \param visitor An arbitrary visitor                /// \pre <tt>matches\<Expr, negate\<T\> \>::::value</tt> is \c true.                /// \return <tt>pass_through\<negate\<T\> \>()(expr, state, visitor)</tt>                template<typename Expr, typename State, typename Visitor>                typename result<void(Expr, State, Visitor)>::type                operator ()(Expr const &expr, State const &state, Visitor &visitor) const                {                    return pass_through<negate>()(expr, state, visitor);                }                /// INTERNAL ONLY                typedef proto::tag::negate proto_tag;                /// INTERNAL ONLY                typedef T proto_arg0;            };            /// \brief A metafunction for generating defereference expression types,            /// a grammar element for matching dereference expressions, and a            /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>            /// transform.            template<typename T>            struct dereference            {

⌨️ 快捷键说明

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