Index: predicate_matcher.hpp =================================================================== --- predicate_matcher.hpp (revision 63304) +++ predicate_matcher.hpp (revision 63305) @@ -29,11 +29,17 @@ template struct predicate_context { - explicit predicate_context(int sub, sub_match_impl const *sub_matches) + explicit predicate_context(int sub, sub_match_impl const *sub_matches, action_args_type *action_args) : sub_(sub) , sub_matches_(sub_matches) + , action_args_(action_args) {} + action_args_type const &args() const + { + return *this->action_args_; + } + // eval_terminal template struct eval_terminal @@ -70,6 +76,26 @@ } }; + template + struct eval_terminal > + { + typedef typename action_arg::reference result_type; + result_type operator()(Expr &expr, predicate_context const &ctx) const + { + action_args_type::const_iterator where_ = ctx.args().find(&typeid(proto::value(expr))); + if(where_ == ctx.args().end()) + { + BOOST_THROW_EXCEPTION( + regex_error( + regex_constants::error_badarg + , "An argument to an action was unspecified" + ) + ); + } + return proto::value(expr).cast(where_->second); + } + }; + // eval template struct eval @@ -88,8 +114,10 @@ {}; #endif + private: int sub_; sub_match_impl const *sub_matches_; + action_args_type *action_args_; }; /////////////////////////////////////////////////////////////////////////////// @@ -137,7 +165,7 @@ template bool match_(match_state &state, Next const &next, mpl::false_) const { - predicate_context ctx(this->sub_, state.sub_matches_); + predicate_context ctx(this->sub_, state.sub_matches_, state.action_args_); return proto::eval(proto::child_c<1>(this->predicate_), ctx) && next.match(state); } };