[Proto] Lazy function test

I am experimenting with the calculator example presented in the proto docs. I am unable to use pow<> when I define it using the make_expr (as preseneted in docs), but when I define it like proto::terminal< struct pow_fun<2> >::type const pow2 = {{}}; it works. I am using it like that in the main calculator_context ctx; ctx.args.push_back(2.0); std::cout << proto::eval( pow2(_1), ctx ) << std::endl; // ok with terminal std::cout << proto::eval( pow2(3.0), ctx ) << std::endl; // ok with terminal How can I make the make_expr version to work? Thanks in anticipation Noman Javed Orléans, France

You need to chaneg your gramamr so it match a pow_ tag and a terminal

joel falcou
You need to chaneg your gramamr so it match a pow_ tag and a terminal
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_exprproto::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
participants (3)
-
joel falcou
-
Noman javed
-
Noman Javed