mirror of
https://github.com/boostorg/phoenix.git
synced 2026-02-14 13:02:10 +00:00
[phoenix]
- some tweaking in the pre-preprocessed files
- simplified the invert example
- added expression::make_foo proto expression generation functionals
- Applied patch form Jeroen
[SVN r71874]
This commit is contained in:
@@ -24,13 +24,15 @@ struct invert_actions
|
||||
using phoenix::evaluator;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// redifining evaluator, this is because MSVC chokes on function types like:
|
||||
// F(G(...))
|
||||
#define evaluator(A0, A1) proto::call<phoenix::evaluator(A0, A1)>
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct invert_actions::when<phoenix::rule::plus>
|
||||
: proto::call<
|
||||
proto::functional::make_expr<proto::tag::minus>(
|
||||
phoenix::expression::make_minus(
|
||||
evaluator(proto::_left, phoenix::_context)
|
||||
, evaluator(proto::_right, phoenix::_context)
|
||||
)
|
||||
@@ -40,7 +42,7 @@ struct invert_actions::when<phoenix::rule::plus>
|
||||
template <>
|
||||
struct invert_actions::when<phoenix::rule::minus>
|
||||
: proto::call<
|
||||
proto::functional::make_expr<proto::tag::plus>(
|
||||
phoenix::expression::make_plus(
|
||||
evaluator(proto::_left, phoenix::_context)
|
||||
, evaluator(proto::_right, phoenix::_context)
|
||||
)
|
||||
@@ -50,7 +52,7 @@ struct invert_actions::when<phoenix::rule::minus>
|
||||
template <>
|
||||
struct invert_actions::when<phoenix::rule::multiplies>
|
||||
: proto::call<
|
||||
proto::functional::make_expr<proto::tag::divides>(
|
||||
phoenix::expression::make_divides(
|
||||
evaluator(proto::_left, phoenix::_context)
|
||||
, evaluator(proto::_right, phoenix::_context)
|
||||
)
|
||||
@@ -60,7 +62,7 @@ struct invert_actions::when<phoenix::rule::multiplies>
|
||||
template <>
|
||||
struct invert_actions::when<phoenix::rule::divides>
|
||||
: proto::call<
|
||||
proto::functional::make_expr<proto::tag::multiplies>(
|
||||
phoenix::expression::make_multiplies(
|
||||
evaluator(proto::_left, phoenix::_context)
|
||||
, evaluator(proto::_right, phoenix::_context)
|
||||
)
|
||||
@@ -90,19 +92,18 @@ void print_expr(Expr const & expr)
|
||||
}
|
||||
|
||||
template <typename Expr>
|
||||
typename boost::result_of<
|
||||
phoenix::evaluator(
|
||||
typename
|
||||
boost::phoenix::result_of::eval<
|
||||
Expr const&
|
||||
, phoenix::result_of::context<int, invert_actions>::type
|
||||
)
|
||||
>::type
|
||||
, phoenix::result_of::context<boost::mpl::void_, invert_actions>::type
|
||||
>::type
|
||||
invert(Expr const & expr)
|
||||
{
|
||||
return
|
||||
phoenix::eval(
|
||||
expr
|
||||
, phoenix::context(
|
||||
int()
|
||||
boost::mpl::void_()
|
||||
, invert_actions()
|
||||
)
|
||||
);
|
||||
@@ -122,7 +123,7 @@ int main()
|
||||
print_expr(_1 * _2 / _3);
|
||||
print_expr(_1 * _2 + _3);
|
||||
print_expr(_1 * _2 - _3);
|
||||
print_expr(phoenix::if_(_1 * _4)[_2 - _3]);
|
||||
print_expr(if_(_1 * _4)[_2 - _3]);
|
||||
|
||||
print_expr(_1 * invert(_2 - _3));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user