Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-06-01 21:51:59


On 06/01/2007 04:56 PM, Eric Niebler wrote:
> Larry Evans wrote:
>>>> for(long ichild=0; ichild<Arity; ++ichild)
>>>> {
>>>> proto::eval(proto::arg_c<Expr,ichild>(expr), *this);
>>>> }
>
>
> That's really not going to work.
Yeah, I knew. I was just using it to illustrate my intension.
> If you #include proto/fusion.hpp, you
> can use fusion::for_each on the children nodes as follows:
>
> fusion::for_each( proto::children_of(expr), myfunc() );
>
Yes! Much simpler. All I had to do was define
   template<typename Child>
   void xmpl_context::operator()(Child const& a_child)
   { proto::eval(a_child.*this)
   }

and then in xmpl_context::eval<Expr>::operator()(a_expr, a_ctx) do:

   fusion::for_each(proto::children_of(a_expr),a_ctx)

Thanks.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk