|
Boost Users : |
Subject: Re: [Boost-users] [Proto] Lazy function test
From: Noman javed (noman_bwp_at_[hidden])
Date: 2010-04-30 07:22:18
joel falcou <joel.falcou <at> lri.fr> writes:
>
> You need to chaneg your gramamr so it match a pow_ tag and a terminal<pow_>
>
Here is my function and the grammar
struct INC_TAG
{
typedef double result_type;
double operator()(double no) const
{
return 1.0+no;
}
};
template<typename Arg>
typename proto::result_of::make_expr<
proto::tag::function
,INC_TAG
,Arg
>::type
inc_(Arg const &arg)
{
return proto::make_expr<proto::tag::function>(INC_TAG(), arg);
}
struct calculator_grammar
: proto::or_<
proto::plus< calculator_grammar, calculator_grammar >
, proto::minus< calculator_grammar, calculator_grammar >
, proto::multiplies< calculator_grammar, calculator_grammar >
, proto::divides< calculator_grammar, calculator_grammar >
, proto::function<proto::terminal<INC_TAG>, calculator_grammar >
, proto::terminal< proto::_ >
>
{};
double d = inc_(_1)(2); // fine
double d = inc_(2); // don't work
Even though i have added the following in the grammar
proto::function<proto::terminal<INC_TAG>, calculator_grammar >
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net