Boost logo

Boost Users :

Subject: [Boost-users] [Proto] Forwarding evaluation via tag
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2009-09-29 09:00:55


I have the following grammar that handles the evaluation of various
matrix classes:

   struct eval_xpr
         : bp::or_< bp::when< bp::terminal< block<bp::_,bp::_> >
                            , _load(bp::_)
>
                  , bp::when< bp::plus< eval_xpr,eval_xpr >
                            , bp::call<
functor<bp::tag::plus>(eval_xpr(bp::_left ), eval_xpr(bp::_right) )
>
>
> {};

As you can see, the functor<T> class is a Callable object but not a
primitive Transform so I use call to be able to forward the proper
things to it. Currently I only play with + but I wanted to know how i
can use proto::tag_of and a clever way to conserve the recursive look so
it works for any operator of any tag. Basically what should I do to have :

bp::when< bp::nary_expr< bp::_, bp::vararg< eval_xpr > >
         , bp::call< functor< ???? >( eval_xpr(????), ???, ??? ) >
>

to work for any tag and any number of parameters while typiong the less
code possible. I *think* I should make a new Primitive Transform that
extarct tags and arguments from bp::_expr and then perform the call to
functor but doesn't this mean I have to explicitly write the code for
1,2,3 etc arguments ?


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