|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-10-22 20:40:17
Author: eric_niebler
Date: 2007-10-22 20:40:16 EDT (Mon, 22 Oct 2007)
New Revision: 40310
URL: http://svn.boost.org/trac/boost/changeset/40310
Log:
fix problem with ->* rewrite in actions, add x->*y as alias for y(x)
Text files modified:
trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp | 54 +++++++++++++++++++++++++++++++--------
trunk/boost/xpressive/proto/fusion.hpp | 9 ++----
2 files changed, 45 insertions(+), 18 deletions(-)
Modified: trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp 2007-10-22 20:40:16 EDT (Mon, 22 Oct 2007)
@@ -40,24 +40,28 @@
{
#if BOOST_VERSION >= 103500
+ struct DataMember
+ : proto::mem_ptr<proto::_, proto::terminal<proto::_> >
+ {};
+
+ template<typename Expr, long N>
+ struct child_
+ : remove_reference<typename mpl::if_<
+ is_const<Expr>
+ , typename proto::result_of::arg_c<Expr, N>::const_reference
+ , typename proto::result_of::arg_c<Expr, N>::reference
+ >::type>
+ {};
+
///////////////////////////////////////////////////////////////////////////////
// mem_ptr_eval
// Rewrites expressions of the form x->*foo(a) into foo(x, a) and then
// evaluates them.
- template<typename Expr, typename Context>
+ template<typename Expr, typename Context, bool IsDataMember = proto::matches<Expr, DataMember>::value>
struct mem_ptr_eval
{
- typedef typename remove_reference<typename mpl::if_<
- is_const<Expr>
- , typename proto::result_of::right<Expr>::const_reference
- , typename proto::result_of::right<Expr>::reference
- >::type>::type right_type;
-
- typedef typename remove_reference<typename mpl::if_<
- is_const<Expr>
- , typename proto::result_of::left<Expr>::const_reference
- , typename proto::result_of::left<Expr>::reference
- >::type>::type left_type;
+ typedef typename child_<Expr, 0>::type left_type;
+ typedef typename child_<Expr, 1>::type right_type;
typedef
typename proto::result_of::arg<
@@ -90,6 +94,32 @@
);
}
};
+
+ ///////////////////////////////////////////////////////////////////////////////
+ // mem_ptr_eval
+ // Rewrites expressions of the form x->*foo into foo(x) and then
+ // evaluates them.
+ template<typename Expr, typename Context>
+ struct mem_ptr_eval<Expr, Context, true>
+ {
+ typedef typename child_<Expr, 0>::type left_type;
+ typedef typename child_<Expr, 1>::type right_type;
+
+ typedef
+ typename proto::result_of::arg<right_type>::type
+ function_type;
+
+ typedef typename boost::result_of<
+ function_type(typename proto::result_of::eval<left_type, Context>::type)
+ >::type result_type;
+
+ result_type operator()(Expr &expr, Context &ctx) const
+ {
+ return proto::arg(proto::right(expr))(
+ proto::eval(proto::left(expr), ctx)
+ );
+ }
+ };
#endif
struct attr_with_default_tag
Modified: trunk/boost/xpressive/proto/fusion.hpp
==============================================================================
--- trunk/boost/xpressive/proto/fusion.hpp (original)
+++ trunk/boost/xpressive/proto/fusion.hpp 2007-10-22 20:40:16 EDT (Mon, 22 Oct 2007)
@@ -86,14 +86,11 @@
template<typename This, typename Expr>
struct result<This(Expr)>
- {
- typedef
- typename Context::template eval<UNREF(Expr)>::result_type
- type;
- };
+ : proto::result_of::eval<UNREF(Expr), Context>
+ {};
template<typename Expr>
- typename result<eval_fun(Expr)>::type
+ typename proto::result_of::eval<Expr, Context>::type
operator()(Expr &expr) const
{
return proto::eval(expr, this->ctx_);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk