x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
extends.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\xpressive\proto\extends.hpp
旋转
特效
属性
历史版本
/////////////////////////////////////////////////////////////////////////////// /// \file extends.hpp /// Macros and a base class for defining end-user expression types // // Copyright 2007 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PROTO_EXTENDS_HPP_EAN_11_1_2006 #define BOOST_PROTO_EXTENDS_HPP_EAN_11_1_2006 #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace proto { /// INTERNAL ONLY /// #define BOOST_PROTO_CONST0 /// INTERNAL ONLY /// #define BOOST_PROTO_CONST1 const /// INTERNAL ONLY /// #define BOOST_PROTO_TEMPLATE_YES_(Z, N) template
/// INTERNAL ONLY /// #define BOOST_PROTO_TEMPLATE_NO_(Z, N) /// INTERNAL ONLY /// #define BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, Data, Const)\ BOOST_PP_IF(N, BOOST_PROTO_TEMPLATE_YES_, BOOST_PROTO_TEMPLATE_NO_)(Z, N)\ typename boost::mpl::apply_wrap1<\ BOOST_PP_TUPLE_ELEM(3, 2, Data)\ , typename boost::proto::result_of::BOOST_PP_CAT(funop, N)<\ BOOST_PP_TUPLE_ELEM(3, 1, Data) BOOST_PROTO_CONST ## Const\ BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A)\ >::type\ >::type const\ operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) BOOST_PROTO_CONST ## Const\ {\ typedef boost::proto::result_of::BOOST_PP_CAT(funop, N)<\ BOOST_PP_TUPLE_ELEM(3, 1, Data) BOOST_PROTO_CONST ## Const\ BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A)\ > funop;\ return BOOST_PP_TUPLE_ELEM(3, 2, Data)::make(\ funop::call(*static_cast
(this) BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, a))\ );\ }\ /**/ /// INTERNAL ONLY /// #define BOOST_PROTO_DEFINE_FUN_OP_CONST(Z, N, Data)\ BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, Data, 1) /// INTERNAL ONLY /// #define BOOST_PROTO_DEFINE_FUN_OP_NON_CONST(Z, N, Data)\ BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, Data, 0) /// INTERNAL ONLY /// #define BOOST_PROTO_DEFINE_FUN_OP(Z, N, Data)\ BOOST_PROTO_DEFINE_FUN_OP_CONST(Z, N, Data)\ BOOST_PROTO_DEFINE_FUN_OP_NON_CONST(Z, N, Data)\ /**/ /// INTERNAL ONLY /// #define BOOST_PROTO_EXTENDS_ARG(z, n, Expr)\ typedef\ typename Expr::BOOST_PP_CAT(proto_arg, n)\ BOOST_PP_CAT(proto_arg, n);\ /**/ #define BOOST_PROTO_EXTENDS(Expr, Derived, Domain)\ Expr expr;\ \ typedef Expr proto_base_expr;\ typedef Domain proto_domain;\ typedef Derived proto_derived_expr;\ typedef typename Expr::proto_tag proto_tag;\ typedef typename Expr::proto_args proto_args;\ typedef typename Expr::proto_arity proto_arity;\ typedef void proto_is_expr_;\ typedef boost::proto::tag::proto_expr fusion_tag;\ \ BOOST_PROTO_IDENTITY_TRANSFORM();\ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_EXTENDS_ARG, Expr)\ \ static Derived const make(Expr const &expr)\ {\ Derived that = {expr};\ return that;\ }\ \ Expr &proto_base()\ {\ return this->expr;\ }\ \ Expr const &proto_base() const\ {\ return this->expr;\ }\ /**/ /// INTERNAL ONLY /// #define BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(Expr, Derived, Domain, Const)\ template
\ typename boost::mpl::apply_wrap1
, typename boost::proto::result_of::as_arg
::type> > >::type const\ operator =(A &a) BOOST_PROTO_CONST ## Const\ {\ typedef boost::proto::expr
, typename boost::proto::result_of::as_arg
::type> > that_type;\ that_type that = {{*static_cast
(this)}, boost::proto::as_arg(a)};\ return Domain::make(that);\ }\ \ template
\ typename boost::mpl::apply_wrap1
, typename boost::proto::result_of::as_arg
::type> > >::type const\ operator =(A const &a) BOOST_PROTO_CONST ## Const\ {\ typedef boost::proto::expr
, typename boost::proto::result_of::as_arg
::type> > that_type;\ that_type that = {{*static_cast
(this)}, boost::proto::as_arg(a)};\ return Domain::make(that);\ }\ /**/ #define BOOST_PROTO_EXTENDS_ASSIGN_CONST(Expr, Derived, Domain)\ BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(Expr, Derived, Domain, 1) #define BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST(Expr, Derived, Domain)\ BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(Expr, Derived, Domain, 0) #define BOOST_PROTO_EXTENDS_ASSIGN(Expr, Derived, Domain)\ BOOST_PROTO_EXTENDS_ASSIGN_CONST(Expr, Derived, Domain)\ BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST(Expr, Derived, Domain)\ /**/ /// INTERNAL ONLY /// #define BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(Expr, Derived, Domain, Const)\ template
\ typename boost::mpl::apply_wrap1
, typename boost::proto::result_of::as_arg
::type> > >::type const\ operator [](A &a) BOOST_PROTO_CONST ## Const\ {\ typedef boost::proto::expr
, typename boost::proto::result_of::as_arg
::type> > that_type;\ that_type that = {{*static_cast
(this)}, boost::proto::as_arg(a)};\ return Domain::make(that);\ }\ \ template
\ typename boost::mpl::apply_wrap1
, typename boost::proto::result_of::as_arg
::type> > >::type const\ operator [](A const &a) BOOST_PROTO_CONST ## Const\ {\ typedef boost::proto::expr
, typename boost::proto::result_of::as_arg
::type> > that_type;\ that_type that = {{*static_cast
(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
\ struct result\ {\ typedef\ typename boost::mpl::apply_wrap1
::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_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_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_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
/// struct my_terminal /// { /// BOOST_PROTO_EXTENDS( /// typename proto::terminal
::type /// , my_terminal
/// , default_domain /// ) /// }; /// /// // ... /// my_terminal
_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
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_ARITY)) #include BOOST_PP_LOCAL_ITERATE() }; /// \brief extends\<\> class template for adding behaviors to a proto expression template /// template
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(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_ARITY)) #include BOOST_PP_LOCAL_ITERATE() }; } // namespace exprns_ }} #endif
extends.hpp
网页地址
文件地址
上一页
8/21
下一页
下载
( 13 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.