make_expr.hpp
来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 1,099 行 · 第 1/4 页
HPP
1,099 行
> { /// If \c Tag is <tt>tag::terminal</tt>, then \c type is a /// typedef for <tt>Domain::apply\<expr\<tag::terminal, /// args0\<A0\> \> \>::::type</tt>. /// /// Otherwise, \c type is a typedef for <tt>Domain::apply\<expr\<Tag, /// argsN\< as_child\<A0\>::::type, ... as_child\<AN\>::::type \> /// \>::::type</tt>, where \c N is the number of non-void template /// arguments, and <tt>as_child\<A\>::::type</tt> is evaluated as /// follows: /// /// \li If <tt>is_expr\<A\>::::value</tt> is \c true, then the /// child type is \c A. /// \li If \c A is <tt>B &</tt> or <tt>cv boost::reference_wrapper\<B\></tt>, /// and <tt>is_expr\<B\>::::value</tt> is \c true, then the /// child type is <tt>ref_\<B\></tt>. /// \li If <tt>is_expr\<A\>::::value</tt> is \c false, then the /// child type is <tt>Domain::apply\<expr\<tag::terminal, args0\<A\> \> /// \>::::type</tt>. /// \li If \c A is <tt>B &</tt> or <tt>cv boost::reference_wrapper\<B\></tt>, /// and <tt>is_expr\<B\>::::value</tt> is \c false, then the /// child type is <tt>Domain::apply\<expr\<tag::terminal, args0\<B &\> \> /// \>::::type</tt>. typedef typename detail::make_expr_< Tag , Domain BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A) >::type type; }; /// \brief Metafunction that computes the return type of the /// \c unpack_expr() function, with a domain deduced from the /// domains of the children. /// /// Use the <tt>result_of::unpack_expr\<\></tt> metafunction to /// compute the return type of the \c unpack_expr() function. /// /// \c Sequence is a Fusion Random Access Sequence. /// /// In this specialization, the domain is deduced from the /// domains of the children types. (If /// <tt>is_domain\<Sequence>::::value</tt> is \c true, then another /// specialization is selected.) template< typename Tag , typename Sequence , typename Void1 BOOST_PROTO_FOR_DOXYGEN_ONLY(= void) , typename Void2 BOOST_PROTO_FOR_DOXYGEN_ONLY(= void) > struct unpack_expr { /// Same as <tt>result_of::make_expr\<Tag, /// fusion::value_at\<Sequence, 0\>::::type, ... /// fusion::value_at\<Sequence, N-1\>::::type\>::::type</tt>, /// where \c N is the size of \c Sequence. typedef typename detail::unpack_expr_< Tag , deduce_domain , Sequence , fusion::BOOST_PROTO_FUSION_RESULT_OF::size<Sequence>::type::value >::type type; }; /// \brief Metafunction that computes the return type of the /// \c unpack_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, typename Sequence> struct unpack_expr<Tag, Domain, Sequence, typename Domain::proto_is_domain_> { /// Same as <tt>result_of::make_expr\<Tag, Domain, /// fusion::value_at\<Sequence, 0\>::::type, ... /// fusion::value_at\<Sequence, N-1\>::::type\>::::type</tt>, /// where \c N is the size of \c Sequence. typedef typename detail::unpack_expr_< Tag , Domain , Sequence , fusion::BOOST_PROTO_FUSION_RESULT_OF::size<Sequence>::type::value >::type type; }; } namespace functional { /// \brief A callable function object equivalent to the /// \c proto::make_expr() function. /// /// In all cases, <tt>functional::make_expr\<Tag, Domain\>()(a0, ... aN)</tt> /// is equivalent to <tt>proto::make_expr\<Tag, Domain\>(a0, ... aN)</tt>. /// /// <tt>functional::make_expr\<Tag\>()(a0, ... aN)</tt> /// is equivalent to <tt>proto::make_expr\<Tag\>(a0, ... aN)</tt>. template<typename Tag, typename Domain BOOST_PROTO_FOR_DOXYGEN_ONLY(= deduce_domain)> struct make_expr { BOOST_PROTO_CALLABLE() template<typename Sig> struct result; template<typename This, typename A0> struct result<This(A0)> { typedef typename result_of::make_expr< Tag , Domain , A0 >::type type; }; /// Construct an expression node with tag type \c Tag /// and in the domain \c Domain. /// /// \return <tt>proto::make_expr\<Tag, Domain\>(a0,...aN)</tt> template<typename A0> typename result_of::make_expr< Tag , Domain , A0 const >::type const operator ()(A0 const &a0) const { return proto::detail::make_expr_< Tag , Domain , A0 const >::call(a0); } // Additional overloads generated by the preprocessor ... #define BOOST_PP_ITERATION_PARAMS_1 \ (4, (2, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>, 2)) \ /**/ #include BOOST_PP_ITERATE() }; /// \brief A callable function object equivalent to the /// \c proto::unpack_expr() function. /// /// In all cases, <tt>functional::unpack_expr\<Tag, Domain\>()(seq)</tt> /// is equivalent to <tt>proto::unpack_expr\<Tag, Domain\>(seq)</tt>. /// /// <tt>functional::unpack_expr\<Tag\>()(seq)</tt> /// is equivalent to <tt>proto::unpack_expr\<Tag\>(seq)</tt>. template<typename Tag, typename Domain BOOST_PROTO_FOR_DOXYGEN_ONLY(= deduce_domain)> struct unpack_expr { BOOST_PROTO_CALLABLE() template<typename Sig> struct result {}; template<typename This, typename Sequence> struct result<This(Sequence)> { typedef typename result_of::unpack_expr< Tag , Domain , typename remove_reference<Sequence>::type >::type type; }; /// Construct an expression node with tag type \c Tag /// and in the domain \c Domain. /// /// \param sequence A Fusion Random Access Sequence /// \return <tt>proto::unpack_expr\<Tag, Domain\>(sequence)</tt> template<typename Sequence> typename result_of::unpack_expr<Tag, Domain, Sequence const>::type const operator ()(Sequence const &sequence) const { return proto::detail::unpack_expr_< Tag , Domain , Sequence const , fusion::BOOST_PROTO_FUSION_RESULT_OF::size<Sequence>::type::value >::call(sequence); } }; /// INTERNAL ONLY /// template<typename Tag, typename Domain> struct unfused_expr_fun { BOOST_PROTO_CALLABLE() template<typename Sig> struct result; template<typename This, typename Sequence> struct result<This(Sequence)> { typedef typename result_of::unpack_expr< Tag , Domain , typename remove_reference<Sequence>::type >::type type; }; template<typename Sequence> typename proto::result_of::unpack_expr<Tag, Domain, Sequence const>::type const operator ()(Sequence const &sequence) const { return proto::detail::unpack_expr_< Tag , Domain , Sequence const , fusion::BOOST_PROTO_FUSION_RESULT_OF::size<Sequence>::type::value >::call(sequence); } }; /// INTERNAL ONLY /// template<typename Tag, typename Domain> struct unfused_expr : fusion::unfused_generic<unfused_expr_fun<Tag, Domain> > { BOOST_PROTO_CALLABLE() }; } /// \brief Construct an expression of the requested tag type /// with a domain and with the specified arguments as children. /// /// This function template may be invoked either with or without /// specifying a \c Domain argument. If no domain is specified, /// the domain is deduced by examining in order the domains of /// the given arguments and taking the first that is not /// \c default_domain, if any such domain exists, or /// \c default_domain otherwise. /// /// Let \c wrap_(x) be defined such that: /// \li If \c x is a <tt>boost::reference_wrapper\<\></tt>, /// \c wrap_(x) is equivalent to <tt>as_arg\<Domain\>(x.get())</tt>. /// \li Otherwise, \c wrap_(x) is equivalent to /// <tt>as_expr\<Domain\>(x)</tt>. /// /// Let <tt>make_\<Tag\>(b0,...bN)</tt> be defined as /// <tt>expr\<Tag, argsN\<B0,...BN\> \>::::make(b0,...bN)</tt> /// where \c Bx is the type of \c bx. /// /// \return <tt>Domain::make(make_\<Tag\>(wrap_(a0),...wrap_(aN)))</tt>. template<typename Tag, typename A0> typename lazy_disable_if< is_domain<A0> , result_of::make_expr< Tag , A0 const > >::type const make_expr(A0 const &a0) { return proto::detail::make_expr_< Tag , deduce_domain
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?