Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3474/proto
Modified Files:
expr.hpp extends.hpp ref.hpp traits.hpp
Log Message:
BOOST_PROTO_EXTENDS, for supporting for expression extensions that are PODs
Index: expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/expr.hpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- expr.hpp 14 Feb 2007 08:03:06 -0000 1.23
+++ expr.hpp 15 Feb 2007 18:38:04 -0000 1.24
@@ -89,6 +89,11 @@
BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_PROTO_ARG, ~)
BOOST_PP_REPEAT_FROM_TO(BOOST_PP_ITERATION(),
BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
+ expr &cast()
+ {
+ return *this;
+ }
+
expr const &cast() const
{
return *this;
Index: extends.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/extends.hpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- extends.hpp 14 Feb 2007 08:03:06 -0000 1.21
+++ extends.hpp 15 Feb 2007 18:38:04 -0000 1.22
@@ -21,18 +21,178 @@
#include <boost/xpressive/proto/traits.hpp>
#include <boost/xpressive/proto/expr.hpp>
#include <boost/xpressive/proto/args.hpp>
+#include <boost/xpressive/proto/traits.hpp>
#include <boost/xpressive/proto/generate.hpp>
#include <boost/xpressive/proto/detail/suffix.hpp>
namespace boost { namespace proto
{
+ /// INTERNAL ONLY
+ ///
+ #define BOOST_PROTO_DEFINE_FUN_OP(Z, N, DATA)\
+ template<typename This BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename
A)>\
+ struct result<This(BOOST_PP_ENUM_PARAMS_Z(Z, N, A))>\
+ : boost::proto::generate<\
+ Domain\
+ , typename boost::proto::result_of::BOOST_PP_CAT(funop, N)<\
+ Derived\
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(\
+ Z\
+ , N\
+ , typename remove_reference<A\
+ , >::type BOOST_PP_INTERCEPT\
+ )\
+ >::type\
+ >\
+ {};\
+ \
+ template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)>\
+ typename boost::proto::generate<\
+ Domain\
+ , typename boost::proto::result_of::BOOST_PP_CAT(funop, N)<\
+ Derived\
+ 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)) const\
+ {\
+ typedef boost::proto::result_of::BOOST_PP_CAT(funop, N)<\
+ Derived\
+ BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A)\
+ > funop;\
+ return boost::proto::generate<Domain, typename funop::type>::make(\
+ funop::call(this->derived() BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z,
N, a))\
+ );\
+ }\
+ /**/
+
+ /// INTERNAL ONLY
+ ///
+ #define BOOST_PROTO_EXTENDS_ARG(z, n, Expr)\
+ typedef\
+ typename Expr::BOOST_PP_CAT(BOOST_PP_CAT(arg, n), _type)\
+ BOOST_PP_CAT(BOOST_PP_CAT(arg, n), _type);\
+ /**/
+
+ #define BOOST_PROTO_EXTENDS(Expr, Derived, Domain)\
+ Expr expr;\
+ \
+ typedef Expr type;\
+ typedef Domain domain;\
+ typedef Derived boost_proto_expr_type_;\
+ typedef typename Expr::tag_type tag_type;\
+ typedef typename Expr::args_type args_type;\
+ typedef typename Expr::arity arity;\
+ typedef void is_boost_proto_expr_;\
+ \
+ 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 &cast()\
+ {\
+ return this->expr;\
+ }\
+ \
+ Expr const &cast() const\
+ {\
+ return this->expr;\
+ }\
+ \
+ Derived const &derived() const\
+ {\
+ return *static_cast<Derived const *>(this);\
+ }\
+ \
+ template<typename Fun>\
+ typename boost::proto::result_of::eval<Expr, Fun>::type\
+ eval(Fun &fun) const\
+ {\
+ return this->expr.eval(fun);\
+ }\
+ \
+ template<typename Fun>\
+ typename boost::proto::result_of::eval<Expr, Fun const>::type\
+ eval(Fun const &fun) const\
+ {\
+ return this->expr.eval(fun);\
+ }\
+ /**/
+
+ #define BOOST_PROTO_EXTENDS_ASSIGN(Expr, Derived, Domain)\
+ template<typename A>\
+ typename boost::proto::generate<Domain,
boost::proto::expr<boost::proto::tag::assign,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A>::type> > >::type const\
+ operator =(A &a) const\
+ {\
+ typedef boost::proto::expr<boost::proto::tag::assign,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A>::type> > that_type;\
+ that_type that = {{this->derived()}, boost::proto::as_arg(a)};\
+ return boost::proto::generate<Domain, that_type>::make(that);\
+ }\
+ \
+ template<typename A>\
+ typename boost::proto::generate<Domain,
boost::proto::expr<boost::proto::tag::assign,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A const>::type> > >::type const\
+ operator =(A const &a) const\
+ {\
+ typedef boost::proto::expr<boost::proto::tag::assign,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A const>::type> > that_type;\
+ that_type that = {{this->derived()}, boost::proto::as_arg(a)};\
+ return boost::proto::generate<Domain, that_type>::make(that);\
+ }\
+ /**/
+
+ #define BOOST_PROTO_EXTENDS_SUBSCRIPT(Expr, Derived, Domain)\
+ template<typename A>\
+ typename boost::proto::generate<Domain,
boost::proto::expr<boost::proto::tag::subscript,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A>::type> > >::type const\
+ operator [](A &a) const\
+ {\
+ typedef boost::proto::expr<boost::proto::tag::subscript,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A>::type> > that_type;\
+ that_type that = {{this->derived()}, boost::proto::as_arg(a)};\
+ return boost::proto::generate<Domain, that_type>::make(that);\
+ }\
+ \
+ template<typename A>\
+ typename boost::proto::generate<Domain,
boost::proto::expr<boost::proto::tag::subscript,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A const>::type> > >::type const\
+ operator [](A const &a) const\
+ {\
+ typedef boost::proto::expr<boost::proto::tag::subscript,
boost::proto::args2<boost::proto::ref<Derived const>, typename
boost::proto::result_of::as_arg<A const>::type> > that_type;\
+ that_type that = {{this->derived()}, boost::proto::as_arg(a)};\
+ return boost::proto::generate<Domain, that_type>::make(that);\
+ }\
+ /**/
+
+ #define BOOST_PROTO_EXTENDS_FUNCTION(Expr, Derived, Domain)\
+ template<typename Sig>\
+ struct result;\
+ \
+ template<typename This>\
+ struct result<This()>\
+ {\
+ typedef typename boost::proto::generate<Domain,
boost::proto::expr<boost::proto::tag::function,
boost::proto::args1<boost::proto::ref<Derived const> > > >::type type;\
+ };\
+ \
+ typename boost::proto::generate<Domain,
boost::proto::expr<boost::proto::tag::function,
boost::proto::args1<boost::proto::ref<Derived const> > > >::type const\
+ operator ()() const\
+ {\
+ typedef boost::proto::expr<boost::proto::tag::function,
boost::proto::args1<boost::proto::ref<Derived const> > > type_type;\
+ that_type that = {{this->derived()}};\
+ return boost::proto::generate<Domain, that_type>::make(that);\
+ }\
+ \
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY),
BOOST_PROTO_DEFINE_FUN_OP, ~)\
+ /**/
+
+ /// \brief extends<> class template for adding behaviors to a proto
expression template
+ ///
template<typename Expr, typename Derived, typename Domain>
struct extends
: Expr
{
typedef Domain domain;
typedef typename Expr::type type;
- typedef void is_boost_proto_extends_private_extends_;
typedef Derived boost_proto_expr_type_;
extends()
@@ -105,41 +265,14 @@
return generate<Domain, expr<tag::function, args1<ref<Derived
const> > > >::make(that);
}
+ /// INTERNAL ONLY
+ ///
#define BOOST_PP_LOCAL_MACRO(N) \
- template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>\
- struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>\
- : generate<\
- Domain\
- , typename result_of::BOOST_PP_CAT(funop, N)<\
- Derived\
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(\
- N\
- , typename remove_reference<A\
- , >::type BOOST_PP_INTERCEPT\
- )\
- >::type\
- >\
- {};\
- template<BOOST_PP_ENUM_PARAMS(N, typename A)>\
- typename generate<\
- Domain\
- , typename result_of::BOOST_PP_CAT(funop, N)<\
- Derived\
- BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)\
- >::type\
- >::type const\
- operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const\
- {\
- typedef result_of::BOOST_PP_CAT(funop, N)<\
- Derived\
- BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)\
- > funop;\
- return generate<Domain, typename funop::type>::make(\
- funop::call(this->derived() BOOST_PP_ENUM_TRAILING_PARAMS(N,
a))\
- );\
- }\
+ BOOST_PROTO_DEFINE_FUN_OP(1, N, ~)\
/**/
+ /// INTERNAL ONLY
+ ///
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
#include BOOST_PP_LOCAL_ITERATE()
};
Index: ref.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/ref.hpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ref.hpp 13 Feb 2007 21:57:21 -0000 1.23
+++ ref.hpp 15 Feb 2007 18:38:04 -0000 1.24
@@ -11,7 +11,9 @@
#include <boost/xpressive/proto/detail/prefix.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/is_const.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/detail/suffix.hpp>
@@ -39,7 +41,8 @@
BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_ARG, _)
- type const &cast() const
+ typename mpl::if_<is_const<Expr>, type const &, type &>::type
+ cast() const
{
return this->expr.cast();
}
Index: traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/traits.hpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- traits.hpp 13 Feb 2007 21:57:21 -0000 1.41
+++ traits.hpp 15 Feb 2007 18:38:06 -0000 1.42
@@ -393,13 +393,13 @@
template<typename Expr>
typename result_of::left<Expr>::reference operator()(Expr
&expr) const
{
- return proto::unref(expr.arg0);
+ return proto::unref(expr.cast().arg0);
}
template<typename Expr>
typename result_of::left<Expr>::const_reference
operator()(Expr const &expr) const
{
- return proto::unref(expr.arg0);
+ return proto::unref(expr.cast().arg0);
}
};
@@ -416,13 +416,13 @@
template<typename Expr>
typename result_of::right<Expr>::reference operator()(Expr
&expr) const
{
- return proto::unref(expr.arg1);
+ return proto::unref(expr.cast().arg1);
}
template<typename Expr>
typename result_of::right<Expr>::const_reference
operator()(Expr const &expr) const
{
- return proto::unref(expr.arg1);
+ return proto::unref(expr.cast().arg1);
}
};
@@ -439,7 +439,7 @@
typename result_of::unref<typename Expr::type::arg0_type>::reference
arg(Expr &expr BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
{
- return proto::unref(expr.arg0);
+ return proto::unref(expr.cast().arg0);
};
/// \overload
@@ -448,7 +448,7 @@
typename result_of::unref<typename
Expr::type::arg0_type>::const_reference
arg(Expr const &expr)
{
- return proto::unref(expr.arg0);
+ return proto::unref(expr.cast().arg0);
};
/// \overload
@@ -548,12 +548,12 @@
{
static typename arg_c::reference call(Expr &expr)
{
- return proto::unref(expr.BOOST_PP_CAT(arg, N));
+ return proto::unref(expr.cast().BOOST_PP_CAT(arg, N));
}
static typename arg_c::const_reference call(Expr const &expr)
{
- return proto::unref(expr.BOOST_PP_CAT(arg, N));
+ return proto::unref(expr.cast().BOOST_PP_CAT(arg, N));
}
};
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs