📄 extends.hpp
字号:
typedef boost::proto::expr< \ boost::proto::tag::subscript \ , boost::proto::args2< \ boost::proto::ref_<Derived BOOST_PROTO_CONST ## Const> \ , typename boost::proto::result_of::as_arg<A>::type \ > \ > that_type; \ that_type that = { \ {*static_cast<Derived BOOST_PROTO_CONST ## Const *>(this)} \ , boost::proto::as_arg(a) \ }; \ return Domain::make(that); \ } \ \ template<typename A> \ typename boost::mpl::apply_wrap1< \ Domain \ , boost::proto::expr< \ boost::proto::tag::subscript \ , boost::proto::args2< \ boost::proto::ref_<Derived BOOST_PROTO_CONST ## Const> \ , typename boost::proto::result_of::as_arg<A const>::type \ > \ > \ >::type const \ operator [](A const &a) BOOST_PROTO_CONST ## Const \ { \ typedef boost::proto::expr< \ boost::proto::tag::subscript \ , boost::proto::args2< \ boost::proto::ref_<Derived BOOST_PROTO_CONST ## Const> \ , typename boost::proto::result_of::as_arg<A const>::type \ > \ > that_type; \ that_type that = { \ {*static_cast<Derived BOOST_PROTO_CONST ## Const *>(this)} \ , boost::proto::as_arg(a) \ }; \ return Domain::make(that); \ } \ /**/ #define BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(Expr, Derived, Domain, 1) #define BOOST_PROTO_EXTENDS_SUBSCRIPT_NON_CONST(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(Expr, Derived, Domain, 0) #define BOOST_PROTO_EXTENDS_SUBSCRIPT(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_SUBSCRIPT_NON_CONST(Expr, Derived, Domain) \ /**/ /// INTERNAL ONLY /// #define BOOST_PROTO_EXTENDS_FUNCTION_(Expr, Derived, Domain) \ template<typename Sig> \ struct result \ { \ typedef \ typename boost::mpl::apply_wrap1< \ Domain \ , typename boost::proto::result_of::funop<Sig, Derived >::type \ >::type \ type; \ }; \ /**/ #define BOOST_PROTO_EXTENDS_FUNCTION_CONST(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_FUNCTION_(Expr, Derived, Domain) \ BOOST_PP_REPEAT_FROM_TO( \ 0 \ , BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY) \ , BOOST_PROTO_DEFINE_FUN_OP_CONST \ , (Expr, Derived, Domain) \ ) \ /**/ #define BOOST_PROTO_EXTENDS_FUNCTION_NON_CONST(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_FUNCTION_(Expr, Derived, Domain) \ BOOST_PP_REPEAT_FROM_TO( \ 0 \ , BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY) \ , BOOST_PROTO_DEFINE_FUN_OP_NON_CONST \ , (Expr, Derived, Domain) \ ) \ /**/ #define BOOST_PROTO_EXTENDS_FUNCTION(Expr, Derived, Domain) \ BOOST_PROTO_EXTENDS_FUNCTION_(Expr, Derived, Domain) \ BOOST_PP_REPEAT_FROM_TO( \ 0 \ , BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY) \ , BOOST_PROTO_DEFINE_FUN_OP \ , (Expr, Derived, Domain) \ ) \ /**/ namespace exprns_ { /// \brief Empty type to be used as a dummy template parameter of /// POD expression wrappers. It allows argument-dependent lookup /// to find Proto's operator overloads. /// /// \c proto::is_proto_expr allows argument-dependent lookup /// to find Proto's operator overloads. For example: /// /// \code /// template<typename T, typename Dummy = proto::is_proto_expr> /// struct my_terminal /// { /// BOOST_PROTO_EXTENDS( /// typename proto::terminal<T>::type /// , my_terminal<T> /// , default_domain /// ) /// }; /// /// // ... /// my_terminal<int> _1, _2; /// _1 + _2; // OK, uses proto::operator+ /// \endcode /// /// Without the second \c Dummy template parameter, Proto's operator /// overloads would not be considered by name lookup. struct is_proto_expr {}; /// \brief extends\<\> class template for adding behaviors to a Proto expression template /// template< typename Expr , typename Derived , typename Domain BOOST_PROTO_FOR_DOXYGEN_ONLY(= default_domain) , typename Tag BOOST_PROTO_FOR_DOXYGEN_ONLY(= typename Expr::proto_tag) > struct extends { extends() : expr() {} extends(extends const &that) : expr(that.expr) {} extends(Expr const &expr_) : expr(expr_) {} BOOST_PROTO_EXTENDS(Expr, Derived, Domain) BOOST_PROTO_EXTENDS_ASSIGN_CONST(Expr, Derived, Domain) BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST(Expr, Derived, Domain) // Instead of using BOOST_PROTO_EXTENDS_FUNCTION, which uses // nested preprocessor loops, use file iteration here to generate // the operator() overloads, which is more efficient. BOOST_PROTO_EXTENDS_FUNCTION_(Expr, Derived, Domain) /// INTERNAL ONLY /// #define BOOST_PP_LOCAL_MACRO(N) \ BOOST_PROTO_DEFINE_FUN_OP_CONST(1, N, (Expr, Derived, Domain)) \ /**/ /// INTERNAL ONLY /// #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY)) #include BOOST_PP_LOCAL_ITERATE() }; /// \brief extends\<\> class template for adding behaviors to a Proto expression template /// template<typename Expr, typename Derived, typename Domain> struct extends<Expr, Derived, Domain, tag::terminal> { extends() : expr() {} extends(extends const &that) : expr(that.expr) {} extends(Expr const &expr_) : expr(expr_) {} BOOST_PROTO_EXTENDS(Expr, Derived, Domain) BOOST_PROTO_EXTENDS_ASSIGN(Expr, Derived, Domain) BOOST_PROTO_EXTENDS_SUBSCRIPT(Expr, Derived, Domain) // Instead of using BOOST_PROTO_EXTENDS_FUNCTION, which uses // nested preprocessor loops, use file iteration here to generate // the operator() overloads, which is more efficient. BOOST_PROTO_EXTENDS_FUNCTION_(Expr, Derived, Domain) /// INTERNAL ONLY /// #define BOOST_PP_LOCAL_MACRO(N) \ BOOST_PROTO_DEFINE_FUN_OP(1, N, (Expr, Derived, Domain)) \ /**/ /// INTERNAL ONLY /// #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY)) #include BOOST_PP_LOCAL_ITERATE() }; } // namespace exprns_}}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -